So I'm doing some self training in my lab. I wanted to create a query looking for value A in field A OR value B in field B and return all records that met that either criteria. Value A is type long and value B is text
I've been trying to use match, multi_match, and boolean filters.
This doesn't work:
GET index/_search
{
"query" : {
"match" : {
"fieldA" : valueA,
"fieldB" : "valueB"
}
}
}
neither does this:
GET index/_search
{
"query" : {
"multi_match" : {
"query" : "valueA valueB",
"fields" : ["fieldA", "fieldB"]
}
}
}
This works:
GET index/_search
{
"_source": ["fieldA","fieldB"],
"size": 500,
"query": {
"bool": {
"should": [
{"match": {
"fieldA": valueA
}},
{"match": {
"fieldB": "valueB"
}
}
]
}
}
}
But there are times where fieldB results get a higher score than fieldA results. So I'm trying to figure out where and how to put boosts. The docs only have the boosts after the entire boolean query, so if I want to adjust the score, do I need to do the following?
GET index/_search
{
"_source": ["fieldA","fieldB"],
"size": 500,
"query": {
"bool": {
"should": [
{"match": {
"fieldA": valueA
}}
],
"should": [
{"match": {
"fieldB": "valueB"
}
},
< where do I add a boost? >
]
}
}
}
Thanks