Accessing FieldData in custom Aggregator in ES 2.1.1

(Rohit Kalhans) #1

I was writing a custom Aggrigation module and till ES 1.7.1 I was using DoubleFieldSource which used to fetch the data from FieldData.

However when upgrading my custom plugin to ES 2.1.1, I found that DoubleFieldSource reads from DocValues even when docValues are not enabled. here is the code snippet from where it does not check if docValues is enabled, it simply reads from docvalues.

  public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
    final NumericDocValues arr = DocValues.getNumeric(readerContext.reader(), field);
    final Bits valid = DocValues.getDocsWithField(readerContext.reader(), field);
    return new DoubleDocValues(this) {

When Trying to use DoubleFIeldSource I get the following error

unexpected docvalues type NONE for field 'fileExtensionId' (expected=NUMERIC). Use UninvertingReader or index with docvalues.

The field fileExtensionId has docValues = false and has been indexed thus. Is there any substitute for DoubleFieldSource ? or is this a bug?

(Ivan Brusic) #2

I would suggest looking at the patches from both Lucene and Elasticsearch
to understand what needs to be changed. I went through a Lucene 4 -> 5
upgrade, but I no longer remember the details. I gain insights by looking
at the diffs, especially in the test classes:
[do not know what the issue number is in Elasticsearch]



(system) #3