My purpose is to combine 2 multi match queries as below. I want MPN or SKU fields must match for each keyword. So keywords "hp" and "301" both must be exist either in MPN or SKU. or either Name or Name.raw should have one of the keyword either "hp" or "301". exact match which are MPN/SKU should have higher score. I wrote query as below but it doesnt return any results although there are documents having these conditions. my questions are,
1) Does must query require keyword to be found in both SKU and MPN
for the multi_match query?
2) Combination of must and should is AND or OR? it looks like AND
for me as it doesn't return any result. if it is AND, how to make it
as OR? I cant find any operator on bool. I tried to wrap in another
should query but it didnt help.
I appreciate also any query suggestion for my purpose.
"from": 0,
"size": 10,
"explain": true,
"query": {
"bool": {
"must": [
{
"multi_match": {
"type": "best_fields",
"query": "hp 301",
"fields": [
"MPN^9",
"SKU^8"
],
"operator": "and"
}
}
],
"should": [
{"multi_match": {
"type": "best_fields",
"query": "hp 301",
"fields": [
"Name.raw2^7.5",
"Name^7"
]
}}
]
}
}