Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.