4

i just want to pass a list of integer/ list of string to save in my elasticsearch data store from my spring boot application. I am sending the request through postman but it gives following error.

"status": 500,
"error": "Internal Server Error",
"message": "Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [abPath] tried to parse field [null] as object, but found a concrete value]"

my model class abPath class variable is configured as follows

@Field( type = FieldType.Integer, store = true)
private List<Integer> abPath;

My Postman request attribute set as follows

"abPath": [1, 2, 3]

if i set "abPath" as null, request is completed without any errors

after that i found a way to save as follows

public class AB{
   private Integer abId;
   // constructor and getter setter
}

//then i update my model
@Field( type = FieldType.Nested)
private List<AB> abPath;

//then postman request updated as follows
"abPath" : [{"abId" : 1}, {"abId" : 2}]

then request completed without any errors..

I want to know is,

is that the way to save integer list or string list into elasticsearch?

is there any other better approaches?

can i save the list of integers or list of strings without wrapping values into any other objects like i did?

2
  • 1
    Can you post your mapping? Commented Apr 17, 2020 at 0:47
  • Can u post your mapping. And the call where you are saving im asuming you are using a Repository. could you post that too Commented Apr 17, 2020 at 15:06

1 Answer 1

1

According to me, the way you have implemented is a good way. With this approach, we can even query on inner fields. I am also managing it in the same way.

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

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.