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][][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( ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField( ~[elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.index.query.QueryShardContext.getForField( ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at$ ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at ~[elasticsearch-6.7.1.jar:6.7.1]
at$100( ~[elasticsearch-6.7.1.jar:6.7.1]
at$2.onResponse( [elasticsearch-6.7.1.jar:6.7.1]
at$2.onResponse( [elasticsearch-6.7.1.jar:6.7.1]
at$4.doRun( [elasticsearch-6.7.1.jar:6.7.1]
at [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun( [elasticsearch-6.7.1.jar:6.7.1]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun( [elasticsearch-6.7.1.jar:6.7.1]
at [elasticsearch-6.7.1.jar:6.7.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_211]
at [?: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:

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
  2. Create the index with the right mapping. See
  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.