Introduction to MOSS Search Query Web Service

Source: Internet
Author: User

SharePoint Server 2007 Search provides a Query Web Service. We can call Web Service to provide the Search function for client applications of non-SharePoint sites.

The URL of the search service in MOSS is:

Http: // Server_Name/[sites/] [Site_Name/] _ vti_bin/search. asmx

 

This Web Service has two methods to submit the search:

Query

Returns the results of a specified query in XML format.

QueryEx

Returns the results of a specified query in the form of an ADO. NET DataSet object.

The two methods not only have different types of returned results, but also have different returned content (including attributes.

Query returns the following content by default:

  • Title
  • Description
  • Date
  • Relevance

QueryEx returns the following content by default:

  • WorkId
  • Rank
  • Title
  • Author
  • Size
  • Path
  • Description
  • Write
  • SiteName
  • CollapsingStatus
  • HitHighlightedSummary
  • HitHighlightedProperties
  • ContentClass
  • IsDocument
  • PictureThumbnailURL

Although the return values of these two methods are different, their parameters are the same: QueryXML.

The QueryXML format is as follows:

<QueryPacket>

<Query>

<QueryId/>

<SupportedFormats>

<Format/>

</SupportedFormats>

<Context>

<QueryText language = "zh-CN" type = "MSSQLFT | STRING"> Query Text </QueryText>

<OriginatorContext/>

</Context>

<Range>

<StartAt/>

<Count/>

</Range>

<Properties name = "property name">

<Property/>

</Properties>

<SortByProperties>

<SortByProperty/>

</SortByProperties>

<EnableStemming/>

<TrimDuplicates/>

<Shortdespecialtermresults/>

<IgnoreAllNoiseQuery/>

<IncludeRelevantResults/>

<Shortdehighconfidenceresults/>

</Query>

</QueryPacket>

If you don't know how to fill in the specific attributes in this section of XML, you can download the MOSS Query Tool (http://www.gotdotnet.com/Community/UserSamples/Details.aspx? SampleGuid = 89b3cda7-aad9-4919-8faf-34ef9b2820. B) This tool can generate XML.

For this XML section, pay attention to the bold Section:

  • Language
    Different languages correspond to different word cutting technologies. For example, English can separate words by space, but Chinese Word cutting is much more complicated. Therefore, you must pay attention to the language of the content to be searched, otherwise, there may be no results.
  • Type

There are two options for the value: STRING or MSSQLFT. The differences and usage are shown in the following table:

QueryText type

QueryText value

Add search range

Example

STRING

Keywords

Add the sub-element Property to the Query element in QueryXML. Each Property corresponds to a Property. The Property name is the Property name that is included in the search range.

<Context> <QueryText language = "zh-CN" type = "STRING"> <! [CDATA [KEYWORDS]> </QueryText> </Context> <Properties name = "PROPERTY_NAME">

<Property/>

MSSQLFT

Ms SQL full-Text retrieval. Query Text must be filled with full-Text retrieval Query statements (specific Query statements can be generated using the MOSS Query Tool mentioned above)

Directly add the attribute name to the full-text search query statement.

<QueryText language = "zh-CN" type = "MSSQLFT"> <! [CDATA [SELECT Title, Rank, Size, Description, Write, Path, PROPERTY_NAME FROM portal .. scope () where freetext (DefaultProperties, 'keyword') order by "Rank" DESC]> </QueryText>

Finally, before calling the Query or QueryEx method, we need to create a "credential" for the client to pass MOSS verification.

If you confirm that the client and the MOSS server are in the same domain and have the permission to perform a search, you can use the default credential:

Qs. Credentials = System. Net. CredentialCache. DefaultCredentials;

If the client is not in the MOSS domain (for example, the client runs on a LINUX platform), you can specify the Search user:

Qs. Credentials = new System. Net. NetworkCredential ("username", "password", "Domain Name ");

This step is required and must be performed before the Query or QueryEx method is called. Otherwise, verification fails.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.