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

In a query packet used in SPServices to do searches on Sharepoint 2010 using jquery, I want to filter the results to only .pdf documents.

How can I do that? The below shows all types of files...

This is what I have so far:

var 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 += "test";
queryText += "</QueryText>";
queryText += "</Context>";

queryText += "<Range><Count>250</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 += "<TrimDuplicates>true</TrimDuplicates>";
queryText += "<IncludeRelevantResults>true</IncludeRelevantResults>";

queryText += "</Query>";
queryText += "</QueryPacket>";
share|improve this question
up vote 1 down vote accepted

On the reference page for the QueryText element, it says that if the type is set to "string", then you are using a keyword query.

When using the Keyword Query Syntax, you can specify property restrictions, and to set a property restriction for PDF files, you use "filetype:pdf". I believe you would add that right in with the free text query for the word you are searching for, so in your example:

queryText += "<QueryText language='en-US' type='STRING'>";
queryText += "test filetype:pdf";
queryText += "</QueryText>";
share|improve this answer
That worked, but is there a way to also set a search scope? – omega Jun 11 '13 at 16:49
Yep, pretty sure it's scope:"your scope name" – Dylan Cristy Jun 11 '13 at 17:30
I tried that, but it's not working. No results are coming up. – omega Jun 13 '13 at 14:57
Hmm, not sure what to tell you then. Maybe try putting it in parentheses? If I go to a search center site, go to advanced search, enter "some phrase" in the "All of these words" box, check off a scope, and hit search, on the results page I can see that the keyword query that was generated by the OOB SharePoint Advanced Search WebPart is: ALL(some phrase) (scope:"My scope name") I didn't find anything about scope in the Keyword Query Syntax reference, so I'm just basing it off seeing that that's how SharePoint formats it. – Dylan Cristy Jun 13 '13 at 15:43
I figured it out, you can do it like this SELECT Title, Rank, Size, Description, Write, Path FROM Scope() WHERE CONTAINS ('test') AND ((\"SCOPE\" = 'YOURSCOPENAME')). – omega Jun 13 '13 at 16:41

Your Answer


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.