how do you get value from an underscore in a string from elasticsearch using querybuilder in java?

yes, you are correct, using keyword field you can achieve the exact match, you need to use the below query

boolQuery.must(termQuery("myObject.code.keyword", value); --> note addition of keyword
var results =;

you can use the analyze API to see the tokens for your indexed documents and search term, and basically your tokens in index must match search terms tokens, in order ES to return the match 🙂

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top