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'> <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> </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><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></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>