0

My Lucene web Index is correctly populated with the field parsed_is_line_manager.

In the BasePerson class, I thus added this field:

[SitecoreIgnore]
[IndexField("parsed_is_line_manager")]
public virtual string IsLineManager { get; set; }

(I tried with bool instead of string without success)

This field, on a site associated to the web index, is always null.

QUESTION

What am I doing wrong?

EDIT: this is my model

[Serializable]
[SitecoreType(TemplateId = "{7D18B94B-CC01-4FC5-AC26-76BB2A7392FB}", AutoMap = true)]
public class BasePerson : ImageTemplate, ITagged<Tag>, IPerson, ISectors<Sector>, IEquatable<BasePerson>, IDivisionMultiSelection
{
    // LOTS OF FIELDS

    [TypeConverter(typeof(IndexableIntToBoolConverter))]
    [IndexField("parsed_is_line_manager")]
    public virtual string IsLineManager { get; set; }

    // MORE FIELDS
}

And this is my IndexableIntToBoolConverter class:

public class IndexableIntToBoolConverter : TypeConverter {
    /// <summary>
    /// Determine if the <param ref="sourceType" /> can be converted from
    /// Hint: This is the type declared in your codebase
    /// </summary>
    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
        return sourceType == typeof(bool) || base.CanConvertFrom(context, sourceType);
    }

    /// <summary>
    /// Determine if the <param ref="destinationType" /> can be converted to
    /// Hint: This is the value you want to store within the index
    /// </summary>
    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
        return destinationType == typeof(int) || base.CanConvertTo(context, destinationType);
    }

    /// <summary>
    /// Convert the object from the index to your type
    /// </summary>
    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
        return value != null && ((int)value >= 1);
    }

    /// <summary>
    /// Convert the object from your type to the index
    /// </summary>
    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
        return ((bool)value) ? 1 : 0;
    }
}
  • Is the field marked as Stored? – Richard Seal Oct 22 at 20:28
  • Yes it is. I can inspect the index with Luke, and it's there. – Emanuele Ciriachi Oct 22 at 20:40
  • Create a new TypeConverter for Int/String to Bool Conversion - I followed this - kylekingsbury.com/… – Abhay Dhar Oct 23 at 7:10
  • The article is about Solr, my index is with Lucene. Would that still work, @AbhayDhar? – Emanuele Ciriachi Oct 23 at 9:06
  • 1
    Why not , IMO typeconverter is searchprovider agnostic – Abhay Dhar Oct 23 at 9:57

Your Answer

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

Browse other questions tagged or ask your own question.