开发者

QueryMalformedException

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:

开发者_JAVA技巧

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜