I want to do the full match query on elastic here is the data:
{
"organizationId": "ec1c691a4b43e65aebdb2ab9481",
"organizationName": "工業區"
}
If I use this code
QueryBuilder QueryBuilder = QueryBuilders.termQuery("organizationName","工");
it will get the data, but it's unreasonable
And I have try the following 2 code
QueryBuilder QueryBuilder = QueryBuilders.matchPhraseQuery("organizationName","工業");
QueryBuilder QueryBuilder = QueryBuilders.matchPhraseQuery("organizationName","業區");
Both return the data, but it's not full match
Can anyone help! Tks
The ElasticSearch documentation about term queries:
Avoid using the term query for text fields.
By default, Elasticsearch changes the values of text fields as part of analysis. This can make finding exact matches for text field values difficult.
To search text field values, use the match query instead.
The match query is the standard query for performing a full-text search, including options for fuzzy matching.
So in your example I would do the following to have exact matching behaviour
QueryBuilders.matchQuery("organizationName", "工業區")
If you only query a part of the name, like 工業 or 業區 ElasticSearch wont return results.