问题
I have a match query that query the fields title1, title2 with param that contains sometimes an empty string.
When the value of the param is empty the query returns no results which is normal.
My question is if it possible to make in one single query , this :
if the param is not an empty string query all documents, otherwise do a normal multi_match query .
The pseudo code of my query:
{
"query" : {
"bool" : {
"must" : {
"multi_match" : {
"query": param,
"fields": [ "title1", "title2" ]
},
"match" : {
"query": { "publish" : true}
}
}
}
}
}
Thanks,
来源:https://stackoverflow.com/questions/30697557/elasticsearch-match-query-with-empty-string-as-a-value-for-field