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

Created a search scope on a discussion list, am querying it, works fine. Created a separate scope (folder related, same site) pointing to an announcement list. I consistently get 0 results when running Search Queries. At the same time, the sharepoint 2010, foundation search webpart is capable of returning results from the announcement list. I use the same query for both. Verified that the scope (after the crawl runs) contains files.

Can you help? Heres my query in case its messed up.

var queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>" 
queryText += "<Query>" 
queryText += "<Range><Count>3000</Count></Range>"; 
queryText += "<Context>" 
queryText += "<QueryText language='en-US' type='MSSQLFT'>" 
queryText += "SELECT Title, Rank, Size, Description, Write, Path FROM SCOPE() WHERE (\"scope\" = '"+scope.replace(/[^a-zA-Z 0-9]+/g,'')+"') AND ( FREETEXT('"+term.replace(/[^a-zA-Z 0-9]+/g,'')+"') OR FREETEXT(*,'\""+term.replace(/[^a-zA-Z 0-9]+/g,'')+"\"') OR CONTAINS('FORMSOF (INFLECTIONAL, \""+term.replace(/[^a-zA-Z 0-9]+/g,'')+"\")') OR CONTAINS('\""+term+"\"') )  AND (NOT CONTAINS(Path,'AllItems.aspx'))  AND (NOT CONTAINS(Path,'DispForm.aspx')) ORDER BY \"Rank\" DESC"
queryText += "</QueryText>" 
queryText += "</Context>" 
queryText += "</Query>" 
queryText += "</QueryPacket>";

Thanks in advance

share|improve this question

1 Answer 1

Try this...

var queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>" 
queryText += "<Query domain='QDomain'>" 
queryText += "<SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats>"; 
queryText += "<Range><Count>3000</Count></Range>"; 
queryText += "<Context>"
queryText += "<QueryText language='en-US' type='MSSQLFT'>" 
queryText += "SELECT Title, Rank, Size, Description, Write, Path FROM SCOPE() WHERE (\"scope\" = '"+scope.replace(/[^a-zA-Z 0-9]+/g,'')+"') AND ( FREETEXT('"+term.replace(/[^a-zA-Z 0-9]+/g,'')+"') OR FREETEXT(*,'\""+term.replace(/[^a-zA-Z 0-9]+/g,'')+"\"') OR CONTAINS('FORMSOF (INFLECTIONAL, \""+term.replace(/[^a-zA-Z 0-9]+/g,'')+"\")') OR CONTAINS('\""+term+"\"') )  AND (NOT CONTAINS(Path,'AllItems.aspx'))  AND (NOT CONTAINS(Path,'DispForm.aspx')) ORDER BY \"Rank\" DESC --"
queryText += "</QueryText>" 
queryText += "</Context>" 
queryText += "</Query>" 
queryText += "</QueryPacket>";

Note the items I added:
- domain='QDomain'
- urn:Microsoft.Search.Response.Document.Document
- placed " --" to the end of the query text immediately after the "ORDER BY." This is an "undocumented feature."

share|improve this answer

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.