Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am migrating from ES 1.7 to 5.2 and refactoring the following code.

ES 1.7

public void prepare(final SearchRequestBuilder searchRequestBuilder) {
        final TermsFacetBuilder labelsFacet = FacetBuilders
                .termsFacet("labels")
                .field("labels");
        searchRequestBuilder.addFacet(labelsFacet);
        searchRequestBuilder.setFrom(start);
        searchRequestBuilder.setSize(size);
    }

with ES 5.2

 public void prepare(final SearchRequestBuilder searchRequestBuilder) {
        TermsAggregationBuilder aggregation = AggregationBuilders.terms("labels").field("labels");
        searchRequestBuilder.addAggregation(aggregation);
        searchRequestBuilder.setFrom(start);
        searchRequestBuilder.setSize(size);
    }

When I fire the search query I am getting the following exception

nested: IllegalArgumentException[Fielddata is disabled on text fields by default. Set fielddata=true on [labels] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.]

I also tried setting the fieldDocValue on SearchRequestBuilder but no luck.

share|improve this question
    
Did you Set fielddata=true on [labels], as the error message said? – Jeremy 19 hours ago
    
@Jeremy, How do we set it? – Santosh 19 hours ago
up vote 1 down vote accepted

As per the error message, you need to enable fielddata in your mapping.

For example, here is a new mapping using fielddata=true on a text field.

PUT my_index/_mapping/my_type
{
  "properties": {
    "my_field": { 
      "type":     "text",
      "fielddata": true
    }
  }
}
share|improve this answer
    
Thanks @Jeremy. Actually, I wanted to set it using Java API. I tried searching on ES documentation but did not found one. – Santosh 18 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.