org.elasticsearch.ElasticsearchException$1: Fielddata is disabled on text fields by default

Could you help me to solver this error?:

[2019-05-02T10:35:37,497][DEBUG][o.e.a.s.TransportSearchAction] [K-elM_U] [magento2_product_1_v52][3], node[K-elM_UTTXCBvlkUTFuglg], [P], s[STARTED], a[id=hUhVYORgQ2GI24nBt3FqDw]: Failed to execute [SearchRequest{searchType=QUERY_THEN_FETCH, indices=[magento2_product_1]...
org.elasticsearch.transport.RemoteTransportException: [K-elM_U][127.0.0.1:9300][indices:data/read/search[phase/query]]
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [myparcel_digital_stamp] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
at org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:779) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.index.query.QueryShardContext.getForField(QueryShardContext.java:166) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.support.ValuesSourceConfig.resolve(ValuesSourceConfig.java:95) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder.resolveConfig(ValuesSourceAggregationBuilder.java:317) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder.doBuild(ValuesSourceAggregationBuilder.java:310) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder.doBuild(ValuesSourceAggregationBuilder.java:37) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.AbstractAggregationBuilder.build(AbstractAggregationBuilder.java:139) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.aggregations.AggregatorFactories$Builder.build(AggregatorFactories.java:335) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:811) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService.createContext(SearchService.java:620) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:595) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:386) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService.access$100(SearchService.java:125) ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:358) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:354) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.search.SearchService$4.doRun(SearchService.java:1085) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.7.1.jar:6.7.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_211]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_211]

You need to change your mapping if you want to run aggs or sorts.

Can you tell me how to do this please?

hi @manue,
You can enable fielddata on an existing text field using the PUT mapping API as follows:

https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html

Thank you! This would be the command to solve my problem? (I use the terminal to interact with Elasticsearch)

curl -XPUT "localhost:7900/*/_settings" -H 'Content-Type: application/json' -d' { "mappings" : { "properties": { "my_field": { "type": "text", "fielddata": true } } }}'

Some comments:

  • You can't change an existing field
  • 7900 port is a port I've never seen in Elasticsearch. Did you change the default 9200 port?

Yes I change the port, it is ok? So, What would be the command that I have to use?

Yes. Not a common practice but why not...

  1. Delete the index (this will remove all your data)
  2. Create the index with the right mapping
  3. Reindex your data

Excuse me again, I'm new to Elasticsearch and I do not understand how to interact with Elasticsearch using the console. Could you help me with the orders that I have to use to solve my problem? Thank you very much for your help

So I'm updating a bit my answer:

  1. Delete the index (this will remove all your data). See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
  2. Create the index with the right mapping. See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings
  3. Reindex your data. I can't help for this as it depends on where the data is coming from.

How can I know the name of my index that I have to do this what you tell me?

I don't know what indices you have created but apparently from the logs magento2_product_1 could be a good candidate.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.