Set Filed data true By default for all fields of a mapping

Hey,
I am upgrading my elastocSearch from 1.4 to 6.2 ,I want to set fielddata property true by default for all the fields of a Mapping.

how can I do It??

plz help!

Are you sure you want to do this?
For what reason you don't want to use doc values?

i have upgraded my es mapping to 6.2.
i am getting error the error Production.

ERROR:
<<<<<<
Fielddata is disabled on text fields by default. Set fielddata=true on [SPT-twist] in order to load fielddata.>>>>>>
and i have to do this
<<<<<
{
"properties": {
"SPT-twist": {
"type": "text",
"fielddata": true
}
}
} >>>>>
{SPT-twist} is a field of mapping.

What is in your SPT-twist field?
What are you doing with this field? Aggs? Sorting? Searching?

I can totally answer to your question but I don't want to "just answer".
I prefer giving you the best practice with elasticsearch.

So if you can share a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are exactly doing. Please, try to keep the example as simple as possible.

Then I'll be able to give you a real advice and not just a technical answer.

1 Like

when I am clicking on pdp (product detail page ) on Production.
I am getting the error>>>>>>>>>

Filed Name:pc-pr-tp

Caused by: NotSerializableExceptionWrapper[: Fielddata is disabled on text fields by default. Set fielddata=true on [pc-pr-tp] 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.]; nested: IllegalArgumentException[Fielddata is disabled on text fields by default. Set fielddata=true on [pc-pr-tp] 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.ElasticsearchException.guessRootCauses(ElasticsearchException.java:618)
at org.elasticsearch.action.search.SearchPhaseExecutionException.guessRootCauses(SearchPhaseExecutionException.java:170)
at org.elasticsearch.action.search.SearchPhaseExecutionException.getCause(SearchPhaseExecutionException.java:111)
at org.elasticsearch.ElasticsearchException.writeTo(ElasticsearchException.java:285)
at org.elasticsearch.action.search.SearchPhaseExecutionException.writeTo(SearchPhaseExecutionException.java:61)
at org.elasticsearch.common.io.stream.StreamOutput.writeException(StreamOutput.java:864)
at org.elasticsearch.ElasticsearchException.writeTo(ElasticsearchException.java:285)
at org.elasticsearch.transport.ActionTransportException.writeTo(ActionTransportException.java:59)
at org.elasticsearch.common.io.stream.StreamOutput.writeException(StreamOutput.java:864)
at org.elasticsearch.transport.TcpTransport.sendErrorResponse(TcpTransport.java:1135)
at org.elasticsearch.transport.TcpTransportChannel.sendResponse(TcpTransportChannel.java:76)
at org.elasticsearch.transport.DelegatingTransportChannel.sendResponse(DelegatingTransportChannel.java:70)
at org.elasticsearch.transport.RequestHandlerRegistry$TransportChannelWrapper.sendResponse(RequestHandlerRegistry.java:120)
at org.elasticsearch.action.support.HandledTransportAction$TransportHandler$1.onFailure(HandledTransportAction.java:77)
at org.elasticsearch.action.search.AbstractSearchAsyncAction.raisePhaseFailure(AbstractSearchAsyncAction.java:220)
... 26 more
Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [pc-pr-tp] 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:288)
at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:111)
at org.elasticsearch.index.query.QueryShardContext.getForField(QueryShardContext.java:173)

Every time for different product I am getting error for the new field.
so I want to set fielddata true for all the fields.

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

And that was not my question.

What are you doing with this field? Aggs? Sorting? Searching?

Searching.

Can you share the search call which leads to this error please?

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