Hi,
Below is my use case,
put /twitter/Company/1
{
"manufacturer": "ABC Technologies"
}
put /twitter/Company/2
{
"manufacturer": "DEF Technologies"
}
put /twitter/Company/3
{
"manufacturer": "Technologies"
}
put /twitter/Company/4
{
"manufacturer": "ABC DEF"
}
My document mappings are formed dynamically.
Now when I search,
GET /twitter/Company/_search
{
"query": {
"match": {
"manufacturer": "Technologies"
}
}
}
I get a response as below,
"manufacturer": "ABC Technologies"
"manufacturer": "DEF Technologies"
"manufacturer": "Technologies"
But my requirement is to fetch only,
"manufacturer": "Technologies"
If I'm not wrong, this Elasticsearch's behavior due to inverted indexing & standard analyzer.
I tried setting "keyword" analyzer for all string fields in dynamic_template as below,
PUT twitter
{
"mappings": {
"default": {
"dynamic_templates": [
{
"string_analyzer": {
"match_mapping_type": "string",
"match": "*",
"mapping": {
"type": "string",
"analyzer": "keyword"
}
}
}
]
}
}
}
It's working fine
Questions:
- What are cons of using "keyword" analyzer (90% of my fields are string type and I can't pre-define my fields as my use case is dynamic json structure) ?
- Is there any better way to achieve my requirement?
Regards,
Sreeram