0
votes

I am configuring a custom search for a Sharepoint application, and I am having trouble forming the FullTextSqlQuery query.

My code earns a QueryMalformedException (Your query is malformed. Please rephrase your query.) when I attempt to execute the query.

Here is my code:

search = new FullTextSqlQuery(site); search.QueryText = string.Format("select Title, Path, Description, Rank, Size FROM SCOPE() WHERE \"scope\" = 'Documents' AND CONTAINS (\"{0}\")", EntreeScope.FormProperties["searchBox"]);

where the value of scope.FormProperties["searchBox"] is the query text and site is the current SPSite. Documents is a defined Search Scope on the default Search Service Application on the server.

Thanks in advance,

Brent

1
Try ' instead of " in the contains()Alex K.

1 Answers

0
votes

Try this out

search = new FullTextSqlQuery(site); search.QueryText = string.Format("select Title, Path, Description, Rank, Size FROM SCOPE() WHERE \"scope\" = 'Documents' AND CONTAINS ('\"{0}\"')", EntreeScope.FormProperties["searchBox"]);

Really just adding single quotes around your contains criteria

Check out CONTAINS Predicate in SharePoint Search SQL Syntax for more details because it depends on what you are trying to achieve.