I'm working on a complex query with multiple keyword fields that are weighted differently (one for category, one for brand, etc) but the query seems to be ignoring the boosts and scoring weird. Here's my query:
Summary
{ "from": 0, "min_score": 5.0, "query": { "bool": { "filter": [ { "match": { "whse": { "query": "9999" } } }, { "bool": { "should": [ { "match": { "partClass": { "query": "Plumbing" } } }, { "match": { "partClass": { "query": "Miscellaneous" } } } ] } }, { "term": { "isDiscontinued": { "value": false } } } ], "should": [ { "prefix": { "partNo": { "boost": 20.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "partNo.keyword": { "boost": 20.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "oEM": { "boost": 15.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "oEM.keyword": { "boost": 15.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "match": { "keyword1": { "boost": 15.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword2": { "boost": 14.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword3": { "boost": 13.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword4": { "boost": 20.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword5": { "boost": 11.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword6": { "boost": 10.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword7": { "boost": 9.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword8": { "boost": 8.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword9": { "boost": 7.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword10": { "boost": 6.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword11": { "boost": 5.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword12": { "boost": 4.0, "query": "wolverine brass faucets" } } }, { "match": { "description": { "query": "wolverine brass faucets" } } } ] } }, "size": 1000 }
And here are my mappings:
Summary
{
"partinfo_20231113_172838": {
"mappings": {
"properties": {
"category": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"filterValue": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"isDiscontinued": {
"type": "boolean"
},
"keyword1": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword10": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword11": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword12": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword2": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword3": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword4": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword5": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword6": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword7": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword8": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keyword9": {
"type": "text",
"analyzer": "customAnalyzerSynonym"
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"make": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"oEM": {
"type": "text",
"analyzer": "keyword",
"index_prefixes": {
"min_chars": 3,
"max_chars": 15
}
},
"partClass": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"partNo": {
"type": "text",
"analyzer": "keyword",
"index_prefixes": {
"min_chars": 3,
"max_chars": 15
}
},
"restrictionCodes": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"salesYTD": {
"type": "integer"
},
"webURL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"whse": {
"type": "short"
}
}
}
}
}
Can anyone help? I'm looking to score queries based on how many words match (with a little fuzziness) with a weight depending on what field.