I am using Elastic builder npm
Using esb.termQuery(Email, "test")
Mapping:
"CompanyName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
Database fields:
"Email": "[email protected]",
"CompanyName": "my company"
Query JSON: { term: { CompanyName: 'my' } }
. or { term: { Email: 'test' } }
Result :
"Email": "[email protected]",
"CompanyName": "my company"
Expectation: No result, need a full-text match, Match here is acting like 'like' or queryStringQuery.
I have 3 filters prefix, exact match, include.
In your example, maybe that you are not specifying any analyzer explicitly in the index mapping, therefore text fields are analyzed by default and the standard analyzer is the default analyzer for them. Refer this SO answer, to get a detailed explanation on this.
The following tokens are generated if no analyzer is defined.
Tokens are:
If you want a full-text search then you can define a custom analyzer with a lowercase filter, lowercase filter will ensure that all the letters are changed to lowercase before indexing the document and searching.
Index Mapping:
Index Data:
Search Query:
Search Result: