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 using the SPServices javascript library to make a search request to sharepoint 2010 search. I am trying this query:

queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>";
queryText += "<Query>";
queryText += "<Context>";
queryText += "<QueryText language='en-US' type='MSSQLFT'>";
queryText += "SELECT Title, Rank, Size, Description, Write, Path FROM portal..scope() WHERE CONTAINS ('test') ORDER BY \"Rank\" DESC";
queryText += "</QueryText>";
queryText += "</Context>";
queryText += "</Query>";
queryText += "</QueryPacket>";


alert(queryText);


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

The result of the query string looks like:

<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'><Query><Context><QueryText language='en-US' type='MSSQLFT'>SELECT Title, Rank, Size, Description, Write, Path FROM portal..scope() WHERE CONTAINS ('test') ORDER BY "Rank" DESC</QueryText></Context></Query></QueryPacket>

And the returned response is:

<ResponsePacket xmlns="urn:Microsoft.Search.Response"><Response domain=""><Status>ERROR_BAD_QUERY</Status><DebugErrorMessage>Your query is malformed. Please rephrase your query.</DebugErrorMessage></Response></ResponsePacket>

Does anyone know what is wrong?

Thanks.

share|improve this question

2 Answers 2

According to MSDN for SharePoint Server search, you specify the scope name in the WHERE clause, as follows:

FROM Scope() WHERE "scope"='All Sites'

So you select string have to be like this

queryText += "SELECT Title, Rank, Size, Description, Write, Path FROM Scope() WHERE CONTAINS ('test') ORDER BY \"Rank\" DESC";
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.