Lucene fields default value in Sitecore 7 -
Lucene fields default value in Sitecore 7 -
is there way forcefulness lucene (in sitecore 7) have default value when there no value associated field? i've been trying empty string or null value comparing on field isn't working. want items particular field not have value excluded result set.
thanks
you can create computed field based on original field. if it's empty, homecoming default value:
class="lang-csharp prettyprint-override">public class nulloremptycomputedfield : icomputedindexfield { public object computefieldvalue(iindexable indexable) { item item = indexable sitecoreindexableitem; if (item == null) homecoming null; // homecoming default value if target field empty if (string.isnullorempty(item["originalfield"])) homecoming "_empty_"; homecoming item["originalfield"]; } public string fieldname { get; set; public string returntype { get; set; } }
see next articles tips on creating computed fields:
computed index fields – sitecore 7 content search sitecore 7: computed index fields lucene sitecore lucene.net sitecore7
Comments
Post a Comment