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
    Commented Jan 26, 2012 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
    Commented Jan 26, 2012 at 13:29
  • 1
    Remember that "value" has to be embraced by '', like this: 'Value'
    – tarjeieo
    Commented Jan 26, 2012 at 13:51
  • 1
    Did you create a managed property 'Tag' on the search server?
    – Matthias
    Commented Jan 26, 2012 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
    Commented Jan 26, 2012 at 14:10

4 Answers 4


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!

  • you can probably revoke the bounty offer now? Commented Feb 1, 2012 at 3:49
  • Well i didn't know i can revoke it!
    – Ziba Leah
    Commented Feb 1, 2012 at 7:07

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


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)


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:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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