4.3 Perform a Query

The protocol client might query for documents which satisfies the following criteria:

  • The document contains the text "get started"

  • The document does not contain the word "vehicle"

  • The title of the document contains the text "example site"

  • The author of the document is either "domainname\username1" or "username2"

The issued query would be:

 "get started" AND NOT vehicle title:"example site" author:domainname\username1 OR author:username2

For this scenario, the protocol client sends the following request message:

 <?xml version="1.0" encoding="utf-8"?>
 <soap12:Envelope
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
   <soap12:Body>
     <Query xmlns="urn:Microsoft.Search">
       <queryXml xsi:type='xsd:string'>
         &lt;QueryPacket xmlns='urn:Microsoft.Search.Query'&gt;
         &lt;Query&gt;
         &lt;Context&gt;
         &lt;QueryText type='STRING' language='en-us' &gt;&quot;get started&quot; AND NOT vehicle title:"example site" author:domainname\username1 OR author:&quot;username2&quot;&lt;/QueryText&gt;
         &lt;LanguagePreference&gt;en-us&lt;/LanguagePreference&gt;
         &lt;/Context&gt;
         &lt;Properties&gt;
         &lt;Property name='path'/&gt;
         &lt;Property name='rank'/&gt;
         &lt;Property name='title'/&gt;
         &lt;Property name='author'/&gt;
         &lt;/Properties&gt;
         &lt;EnableStemming&gt;
         true
         &lt;/EnableStemming&gt;
         &lt;/Query&gt;
         &lt;/QueryPacket&gt;
       </queryXml>
     </Query>
   </soap12:Body>
 </soap12:Envelope>

The query information in the preceding message is doubly encoded XML. The following shows the decoded value of the Query string:

 <QueryPacket xmlns='urn:Microsoft.Search.Query'>
   <Query>
     <Context>
       <QueryText type='STRING' language='en-us' >
         "get started" AND NOT vehicle title:"example site" author:domainname\username1 OR author:"username2"
       </QueryText>
       <LanguagePreference>en-us</LanguagePreference>
     </Context>
     <Properties>
       <Property name='path'/>
       <Property name='rank'/>
       <Property name='title'/>
       <Property name='author'/>
     </Properties>
     <EnableStemming>
       true
     </EnableStemming>
   </Query>
 </QueryPacket>

This might be a protocol server’s response to this message:

 <?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope 
   xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
     <QueryResponse xmlns="urn:Microsoft.Search">
       <QueryResult>&lt;ResponsePacket xmlns="urn:Microsoft.Search.Response"&gt;&lt;Response&gt;&lt;Range&gt;&lt;StartAt&gt;1&lt;/StartAt&gt;&lt;Count&gt;2&lt;/Count&gt;&lt;TotalAvailable&gt;2&lt;/TotalAvailable&gt;&lt;Results&gt;&lt;Document xmlns="urn:Microsoft.Search.Response.Document"&gt;&lt;Action&gt;&lt;LinkUrl&gt;http://example.com&lt;/LinkUrl&gt;&lt;/Action&gt;&lt;Properties xmlns="urn:Microsoft.Search.Response.Document.Document"&gt;&lt;Property&gt;&lt;Name&gt;path&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;http://example.com&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;rank&lt;/Name&gt;&lt;Type&gt;Int64&lt;/Type&gt;&lt;Value&gt;78543522&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;title&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;Example Site&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;author&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;DOMAINNAME\USERNAME1&lt;/Value&gt;&lt;/Property&gt;&lt;/Properties&gt;&lt;/Document&gt;&lt;Document xmlns="urn:Microsoft.Search.Response.Document"&gt;&lt;Action&gt;&lt;LinkUrl fileExt="aspx"&gt;http://example.com/Lists/Announcements/AllItems.aspx&lt;/LinkUrl&gt;&lt;/Action&gt;&lt;Properties xmlns="urn:Microsoft.Search.Response.Document.Document"&gt;&lt;Property&gt;&lt;Name&gt;path&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;http://example.com/Lists/Announcements/AllItems.aspx&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;rank&lt;/Name&gt;&lt;Type&gt;Int64&lt;/Type&gt;&lt;Value&gt;75711418&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;title&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;Example Site - Announcements&lt;/Value&gt;&lt;/Property&gt;&lt;Property&gt;&lt;Name&gt;author&lt;/Name&gt;&lt;Type&gt;String&lt;/Type&gt;&lt;Value&gt;Username2&lt;/Value&gt;&lt;/Property&gt;&lt;/Properties&gt;&lt;/Document&gt;&lt;/Results&gt;&lt;/Range&gt;&lt;Status&gt;SUCCESS&lt;/Status&gt;&lt;/Response&gt;&lt;/ResponsePacket&gt;</QueryResult>
     </QueryResponse>
   </soap:Body>
 </soap:Envelope>

The query information in the preceding message is doubly encoded XML. The following shows the decoded value of the QueryResponse string:

 <ResponsePacket xmlns="urn:Microsoft.Search.Response">
   <Response>
     <Range>
       <StartAt>1</StartAt>
       <Count>2</Count>
       <TotalAvailable>2</TotalAvailable>
       <Results>
         <Document xmlns="urn:Microsoft.Search.Response.Document">
           <Action>
             <LinkUrl>http://example.com</LinkUrl>
           </Action>
           <Properties xmlns="urn:Microsoft.Search.Response.Document.Document">
             <Property>
               <Name>path</Name>
               <Type>String</Type>
               <Value>http://example.com</Value>
             </Property>
             <Property>
               <Name>rank</Name>
               <Type>Int64</Type>
               <Value>78543522</Value>
             </Property>
             <Property>
               <Name>title</Name>
               <Type>String</Type>
               <Value>Example Site</Value>
             </Property>
             <Property>
               <Name>author</Name>
               <Type>String</Type>
               <Value>DOMAINNAME\USERNAME1</Value>
             </Property>
           </Properties>
         </Document>
         <Document xmlns="urn:Microsoft.Search.Response.Document">
           <Action>
             <LinkUrl fileExt="aspx">http://example.com/Lists/Announcements/AllItems.aspx</LinkUrl>
           </Action>
           <Properties xmlns="urn:Microsoft.Search.Response.Document.Document">
             <Property>
               <Name>path</Name>
               <Type>String</Type>
               <Value>http://example.com/Lists/Announcements/AllItems.aspx</Value>
             </Property>
             <Property>
               <Name>rank</Name>
               <Type>Int64</Type>
               <Value>75711418</Value>
             </Property>
             <Property>
               <Name>title</Name>
               <Type>String</Type>
               <Value>Example Site - Announcements</Value>
             </Property>
             <Property>
               <Name>author</Name>
               <Type>String</Type>
               <Value>Username2</Value>
             </Property>
           </Properties>
         </Document>
       </Results>
     </Range>
     <Status>SUCCESS</Status>
   </Response>
 </ResponsePacket>