Reputation: 45
have 4 different results in such kind of queries:
GET _search
{
"query": {
"query_string": {
"default_field": "desc",
"query": "лес"
}
}
}
GET _search
{
"query": {
"query_string": {
"default_field": "desc",
"query": "лес*"
}
}
}
GET _search
{
"query": {
"query_string": {
"default_field": "desc",
"query": "*лес"
}
}
}
GET _search
{
"query": {
"query_string": {
"default_field": "desc",
"query": "*лес*"
}
}
}
The difference is the asterisk position. Is it possible to get results from all four queries in one ?
Upvotes: 0
Views: 250
Reputation: 2547
if you don't need to differentiate what query has determined a successful hit, then you can just use a boolean should
query. Something like
{
"query": {
"bool": {
"should": [
{
"query_string": {
"default_field": "desc",
"query": "лес"
}
},
{
"query_string": {
"default_field": "desc",
"query": "лес*"
}
},
...
]
}
}
}
Update with some recommendations on the queries:
*nec
, nec*
, and *nec*
for. If you are going to combine them, and you don't need to differentiate the hit match, isn't *nec*
enough? match_query
to match
(first query), prefix
and wildcard
(on the other queries, if you have non-analysed sub-fields available)Upvotes: 2