I am pretty new to elasticsearch and just need some clarification: Can we define a analyzer while querying the search server. I tried it with the \"text\" and \"field\" query an
The term
, prefix
, and wildcard
queries expect the value specified in the query to be already analyzed.
This syntax worked for me:
GET /_search
{
"query": {
"match_phrase": {
"controller": {
"analyzer": "keyword",
"query": "api/v2/test"
}
}
}
}
Find more details in the documentation.
You can set a custom search-analyzer to be used for queries.
From the docs:
Usually, the same analyzer should be applied at index time and at search time, to ensure that the terms in the query are in the same format as the terms in the inverted index.
Sometimes, though, it can make sense to use a different analyzer at search time, such as when using the analysis-edgengram-tokenizer for autocomplete.
By default, queries will use the
analyzer
defined in the field mapping, but this can be overridden with thesearch_analyzer
setting
The docs also list an example. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html