Reputation: 127
I have an expression/query : ("text" started_with "hello" OR "text" started_with "hi") OR ("select" is "first_option" AND "correct" is "true" ) . Can you show me the way to use both of bool and filter query correctly in Elastic Search to solve this expression?
Upvotes: 0
Views: 448
Reputation: 2000
You can achieve the given expression/query using "prefix query" along with boolean query and term query. Try as follows
{
"bool": {
"should": [
{
"prefix": {
"text": {
"value": "hello"
}
}
},
{
"prefix": {
"text": {
"value": "hi"
}
}
},
{
"bool": {
"must": [
{
"term": {
"select": [
"first_option"
]
}
},
{
"term": {
"correct": [
"true"
]
}
}
]
}
}
]
}
}
Upvotes: 2