Wednesday, October 12, 2011

Sitecore Search and Standard Values

As far as I am able to tell, it is not possible to do a Sitecore.Search (Lucene) fieldquery (or any other query for that matter) that will return items using the standard value for the field you're querying.

For example - Let's say you have an item with a checkbox field "DisplayOnPage", and the standard values for the Items template has "DisplayOnPage" set to be checked by default (thus the standard value for this field is "1").  If you do a field query against an index containing your item, and look for items where "displayonpage" = "1", your item that is using the standard value (again, to set the value of the DisplayOnPage field to 1) will NOT return as a result.  If, on your item, you uncheck the DisplayOnPage field, save the item, then recheck the DisplayOnPage field, save again and publish - your item will be returned by your FieldQuery. 

I believe the cause to this is that standard value fields are not stored by items explicitly in the database, so the Sitecore Search doesn't make the connection that your item implicitly has the value you're searching for.

No comments:

Post a Comment