Share via


Enterprise Search Query Web Service Overview

Enterprise Search in Microsoft Office SharePoint Server 2007 exposes its search functionalities through an XML Web service. This allows you to access Enterprise Search results from client applications and Web applications outside of the context of a SharePoint site.

Accessing the Query Web Service

To access the Enterprise Search Query Web service and its methods, set a Web reference to the following:

http://Server_Name/[sites/][Site_Name/]_vti_bin/search.asmx

Note

For step-by-step instructions for setting a Web reference with Microsoft Visual Studio 2005, see How to: Create a Web Service Proxy Class for the Enterprise Search Query Web Service in Visual Studio 2005.

Search in Windows SharePoint Services also provides a Query Web service for exposing its search functionality, which supports the same Web methods as the Enterprise Search Query Web service, but which returns Search in Windows SharePoint Services results and which is scoped to the containing site or list. The location for the Search in Windows SharePoint Services Query Web service is:

http://Server_Name/[sites/][Site_Name/]_vti_bin/spsearch.asmx

For more information, see the Windows SharePoint Services Search Query Web Service in the Windows SharePoint Services 3.0 SDK.

Web Methods

The following table describes the Web methods available in the Query Web service.

Name Description

GetPortalSearchInfo

Returns a list of scopes.

GetSearchMetadata

Returns a list of managed properties and scopes.

Query

Returns a set of results in an XML string for the specified query.

QueryEx

Returns a set of results in a Microsoft ADO.NET DataSet object for the specified query.

Registration

Returns the name for a specified site.

Status

Returns availability of the search service.

Query Methods

The Query Web service includes two methods for retrieving Enterprise Search results: Query and QueryEx.

Both methods accept the same input, a string containing XML that specifies the search query parameters; however, the format of the returned results differs. The QueryEx method returns the search results in a System.Data.DataSet object, and the Query method returns the search results in a string as XML. For more information, see Returning the Search Results.

Choosing the Query Web Service Method

To return multiple result types—such as relevant, special terms, and high confidence types—in the search results, you must use the QueryEx method.

Building the XML for the Search Query

The XML format for the search query is defined in the Microsoft.Search.Query Schema for Enterprise Search schema.

The actual search query is specified in the QueryText Element in Microsoft.Search.Query Schema for Enterprise Search element. You can build the search query by using either the Enterprise Search SQL Syntax Reference syntax or Enterprise Search Keyword Syntax Reference syntax; you specify the syntax that is used in the QueryText element's type attribute.

The following code example is sample XML for the QueryText element that specifies a search query using SQL syntax.

<QueryText language=xml:lang type='MSSQLFT'>
SELECT Title, Path, Description, Write, Rank, Size FROM Scope() WHERE CONTAINS(Description,'SharePoint')
</QueryText>

Note

If you are using SQL syntax with the Query method, you must specify the following properties in the SELECT statement of the SQL query: Title, Path, Description, Write, Rank, and Size.

The following code example is sample XML for the QueryText element that specifies a search query using Keyword syntax.

<QueryText language=xml:lang type='STRING'>
SharePoint
</QueryText>

You can specify which properties to return for the keyword query using the Property Element in Microsoft.Search.Query Schema for Enterprise Search element.

If you do not specify any properties in the query XML, Enterprise Search returns a default set of properties.

Following are the default set of properties returned for the Query method:

  • Title

  • Description

  • Date

  • Relevance

Following are the default set of properties returned for the QueryEx method:

  • WorkId

  • Rank

  • Title

  • Author

  • Size

  • Path

  • Description

  • Write

  • SiteName

  • CollapsingStatus

  • HitHighlightedSummary

  • HitHighlightedProperties

  • ContentClass

  • IsDocument

  • PictureThumbnailURL

Returning the Search Results

The QueryEx method returns the search results in a System.Data.DataSet object. The DataSet object contains a System.DataSet.DataTable object for each result type that is returned. The different result types that can be returned are:

  • Relevant, in a table named RelevantResults

  • High confidence, in a table named HighConfidenceResults

  • Special terms, in a table named SpecialTermsResults

The Query method returns the search results in a string as XML. The format for the XML is defined by the Microsoft.Search.Response Schema for Enterprise Search and Microsoft.Search.Response.Document Schema for Enterprise Search schemas. The full set of search results is contained in the Results Element in Microsoft.Search.Response Schema for Enterprise Search element of the Microsoft.Search.Response schema, with each individual result represented by a Document Element in Microsoft.Search.Response.Document Schema for Enterprise Search element of the Microsoft.Search.Response.Document schema.

Note

The only result type supported by the Query method is relevant results.

In This Section

How to: Create a Web Service Proxy Class for the Enterprise Search Query Web Service in Visual Studio 2005

How to: Submit a Keyword Query to Enterprise Search from a Client Application

Reference

QueryService

Microsoft.Search Schema Reference for Enterprise Search

Enterprise Search SQL Syntax Reference

Enterprise Search Keyword Syntax Reference

Related Sections

Managing Metadata

Working with Search Scopes

Building Enterprise Search Queries

See Also

Other Resources

Windows SharePoint Services Search Query Web Service