SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am doing a search using this code:

var queryText;
queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>";
queryText += "<Query>";
queryText += "<SupportedFormats>";
queryText += "<Format>urn:Microsoft.Search.Response.Document.Document</Format>";
queryText += "</SupportedFormats>";
queryText += "<Context>";
queryText += "<QueryText language='en-US' type='STRING'>";
queryText += text;
queryText += "</QueryText>";
queryText += "</Context>";
queryText += "<Range><Count>1000</Count></Range>";
queryText += "<Properties>";
queryText += "<Property name='Title'></Property>";
queryText += "<Property name='Path'></Property>";
queryText += "<Property name='Description'></Property>";
queryText += "<Property name='Write'></Property>";
queryText += "<Property name='Rank'></Property>";
queryText += "<Property name='Size'></Property>";
queryText += "</Properties>";
//queryText += "<SortByProperties>";
//queryText += "<SortProperty name='Title' direction='ascending' order="1"></SortProperty>";
//queryText += "</SortByProperties>";
queryText += "<EnableSpellCheck>false</EnableSpellCheck>";
queryText += "<TrimDuplicates>false</TrimDuplicates>";
queryText += "<IncludeRelevantResults>false</IncludeRelevantResults>";
queryText += "</Query>";
queryText += "</QueryPacket>";


$().SPServices({
    operation: "Query",
    queryXml: queryText,
    completefunc: searchComplete
});

However, I want to set the search scope to a specific library. How can I do this?

Thanks

share|improve this question
up vote 1 down vote accepted

Piecing together 2 articles (MSDN and 2), it looks as if your QueryText section should be like this:

<QueryText language=xml:lang type='MSSQLFT'>
SELECT Title,shortdescription,description,Rank, FROM portal..scope() WHERE
CONTAINS ('"test*"')   AND  ( ("SCOPE" = 'TestScope') )  ORDER BY "Rank" DESC
</QueryText>

I had looked into this before, but we ripped the functionality out of the site. Anita has some useful posts on the search web service and SPServices.

share|improve this answer
    
I got it working with the solution here social.msdn.microsoft.com/Forums/en-US/… – omega Jun 13 '13 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.