Search Not Applying Scores Properly - Ignoring Boosts

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.

Hey @mmobley,

Have you ran the query with explain: true in the search body? That should tell you the scoring calculation used.

Another thing to do is to add _name to each of your queries: Boolean query | Elasticsearch Guide [8.11] | Elastic

This way you can see for sure which query matched for each document. Its even better with adding the include_named_queries_score parameter, which returns by how much each query contributes to the overall score.

Hey @mmobley,

Can you also share the analyzer config here? Further to what @BenTrent said. I think your search term is getting satisfied by multiple queries which inturn results in a normalized score. explain: true parameter as part of your search body is your best friend here.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.