Elasticsearch: how to execute a query using quoted partial phrases
I am trying to implement a search behavior that supports partial phrases. A possible search entry might look like this:
example "hello world" elasticsearch
Now I want to get all documents containing words example
and elasticsearch
as well as the phrase hello world
.
Since this is a very typical use case for searches, I was surprised that I couldn't find much on this topic.
I tried several approaches (templated tokenizer, picture grab filter), but none of them worked as expected. Before I start implementing a dedicated approach for creating a complex query definition programmatically, is there a recommended way to achieve this?
Any help is greatly appreciated!
source to share
query_string will do exactly that.
{
"query": {
"query_string": {
"query": "example \"hello world\" elasticsearch",
"default_operator": "AND"
}
}
}
source to share