I've got a site collection on a Sharepoint Foundation 2010. I've Search Express also installed.. When i wrote down in the search box something like "Parameter:Value" it returns me the right elements (so i've configured well column and crawler)..

Now i want (by code) write a query that gets every item with that column and respect some value.. So, make the same thing, but coding it!

        string searchQuery = "select Title from scope() WHERE Tag = 'Value' "; 

        // Execute the query.
        FullTextSqlQuery query = new FullTextSqlQuery(SPContext.Current.Site);
        query.ResultTypes = ResultType.RelevantResults;
        query.QueryText = searchQuery;
        ResultTableCollection searchResults = query.Execute();

It cannot execute the query... Tag is the field i've defined and works writing down the Tag:Value from search box!

Can anyone suggest me what's wrong with my query?

Thank you very much!!

  • 2
    There is the 'WHERE' missing in you query: select Title from scope() WHERE Tag = Value – Matthias Jan 26 '12 at 12:45
  • Thank you, but doesn't work anyway! "Property doesn't exist or is used in a manner inconsistent with schema settings." – Ziba Leah Jan 26 '12 at 13:29
  • 1
    Remember that "value" has to be embraced by '', like this: 'Value' – tarjeieo Jan 26 '12 at 13:51
  • 1
    Did you create a managed property 'Tag' on the search server? – Matthias Jan 26 '12 at 13:58
  • Embraced just now, but doesn't work! Tag in the search server works.. If i wrote down Tag:value in a search box, this returns me the right object! – Ziba Leah Jan 26 '12 at 14:10

The problem i've encountered was linked to the reference i was using.. I used


instead of


In the version i was using it was impossibile to query sharepoint giving him parameters and so on... But the firm of every class and method was the same..

Now it works!

Thanks to all!

| improve this answer | |
  • you can probably revoke the bounty offer now? – Alexey Krasheninnikov Feb 1 '12 at 3:49
  • Well i didn't know i can revoke it! – Ziba Leah Feb 1 '12 at 7:07

Try using the KeywordQuery class instead, that should mimic the search box behaviour as far as I'm aware.

| improve this answer | |

Download Fast Search Tool from Codeplex, use UI to construct the query, and test. Repeat until you get it working. (I have nothing to do with the tool, I have just used it for similar purposes)

| improve this answer | |

I'm guessing that Tag is a Managed metadata column? If so, doing an equals compare using Column = 'Value' won't work, as the actual text in the property could potentially hold more values, lookup value based managed metadata properties store the values differently in the index.

So you would have to use a CONTAINS or a LIKE. Any search using a lookup column in the WHERE clause (and taxonomy fields are lookup columns) needs to be a done like that.

The query would be something like:

| improve this answer | |
  • It doesn't work anyway... In Search Server Tag is a Managed metadata column.. Searched, crawled and reachable by standard search box! – Ziba Leah Jan 31 '12 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.