lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harry Yoo <h...@vbi.vt.edu>
Subject Re: Best way to facets with value preprocessing (w/ docValues)
Date Tue, 14 Jul 2015 18:59:29 GMT
I had a same issue and here is my solution.

Basically, option #1 that Konstantin suggested,

public class TextDocValueField extends TextField {

  @Override
  public List<IndexableField> createFields(SchemaField field, Object value, float boost)
{
    if (field.hasDocValues()) {
      List<IndexableField> fields = new ArrayList<>();
      fields.add(createField(field, value, boost));
      final BytesRef bytes = new BytesRef(value.toString());
      if (field.multiValued()) {
        fields.add(new SortedSetDocValuesField(field.getName(), bytes));
      } else {
        fields.add(new SortedDocValuesField(field.getName(), bytes));
      }
      return fields;
    } else {
//      return Collections.singletonList(createField(field, value, boost));
      return super.createFields(field, value, boost);
    }
  }

  @Override
  public void checkSchemaField(final SchemaField field) {
    // do nothing
  }

  @Override
  public boolean multiValuedFieldCache() {
    return false;
  }
}


I had no problem so far, but I haven’t compared performance. I wish Solr allows docValue
on TextField

Best,
Harry





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message