0

i'm facing an index issue. In my Spring document, I have a map. This map can contains thousands of data because I save history.

private NavigableMap<String, Integer> installHistory = new TreeMap<>();

In elastic search all data in my map are index, and I got a limit exeed error.

enter image description here

How could I do to not index all data inside the Map ? I use spring 2.2 and spring elastic search 3.2.4

Thanks in advance.

Edit : I upgrade to spring data elastic 4.0.1 to use FielType.Flattened, but spring data elastic 4.0.1 supports min version of elasticsearch 7.6.X. My version is 7.4 and I can't change it because it is the latest version provided by aws.

I made the field transient, and created a String property for this Map. Before saving my object i convert the map into list and put it in the String variable.

2 Answers 2

2

A map is converted to a JSON object that has the map keys as properties and the map values as values. So you end up storing objects with thousands of properties, see the Elasticsearch documentation about this.

You could declare the type of the installHistory with FieldType.Flattened

Edit:

I missed that you are using Spring Data Elasticsearch 3.2.x. Support for the flattened field type was added in 4.0.

The best thing then would probably be to convert the Map property to a List of Pairs or Tupels, where each Pair contains a key-value pair from the map.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I did something very dirty. I declare my map has transient and created a string version of the map...But i'm going to remove it and keep the flattened solution. Thanks
I don't have Flattened in the list of FieldType
0

Did you try these Custom Converters provided in the Documentation https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.mapping.meta-model.conversions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.