Closed motoyugota closed 11 years ago
Here's how I updated the GetValue method in that class. Let me know if this is correct or not.
public override string GetValue()
{
var value = String.Empty;
if (FieldTypeManager.GetField(_field) is LookupField)
{
var lookupField = new LookupField(_field);
value = lookupField.TargetItem == null ? "" : lookupField.TargetItem.DisplayName;
}
if (FieldTypeManager.GetField(_field) is ReferenceField)
{
var referenceField = new ReferenceField(_field);
value = referenceField.Value;
}
return value;
}
Hello,
It used to return the display name as your code above but then I realized that when the display name changes, the item referrer item will not be updated, so this change will not make it to the index. So I switched back to storing the guid of the target item. The comment for this method is wrong. You can alter this for your needs, however beware of this behavior.
NormalizeGuid is necessary so you can search by GUID in Lucene's default configuration. If you pass back the guid in the original state to Lucene, you won't be able to do field query on that. It's gotta be shortened and lowercased.
Fixed the misleading comment in sitecorian/SitecoreSearchContrib@64f579e2f7a26382a3aab0adeff71d4a1d2efea9
LookupFieldCrawler says this in its summary comment:
/// Returns lookup field value as an item display name instead of item ID.
However, the code is doing this:
Shouldn't that code be getting the display name instead of calling "NormalizeGuid"? All that does is puts the Guid into the index minus the dashes.