3

I am loading my sql data tables into it and wish to get results depending upon various requirements. I am having a problem in rangequery. When I am writing this:

$ curl -X GET 'http://localhost:9200/sample/new/_search?pretty=true' -d '
{ query:{range:{price_incl_tax:{gte:1000,lte:1500}}} }'

the results where price_incl_tax=140.0000 as well as 13500.0000 are also coming.

1 Answer 1

3

In your case, price_incl_tax seems to be stored as a string. It probably happend because the price_incl_tax field was initially added as a string instead of a number. You can verify field types in your index by running

$ curl -X GET 'http://localhost:9200/sample/new/_mapping?pretty=true'

Elasticsearch allows you to control individual field types by specifying mapping during index or type creation.

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

3 Comments

Thanks for your answer. This was exactly the problem.
I would also like to know if the mapping can be updated or it has to be recreated all over again.
In general, you can only add new fields to an existing mapping. A field type of an existing field cannot be changed. So, in your case you will have to recreate the index.

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.