I am making a recommender with Elasticsearch. I know what people have bought and this forms the query. The index is of items and has a field that contains items bought in common.
In previous versions of ES (<= 5.6) the two queries below resulted in different scores and therefor different rankings
Here is what I found in ES 6.5
{
"query": {
"bool": {
"should": [
{
"terms": {
"bought": [
"iPad Pro"
]
}
}
]
}
}
}
returns items, all with score = 1.0. This might make sense because each of the items has "iPad Pro" in its "bought" field.
But the following query:
{
"query": {
"bool": {
"should": [
{
"terms": {
"bought": [
"iPad Pro",
"iPhone 8"
]
}
}
]
}
}
}
also returns exactly the same items with scores of 1.0. This is not what I expected and does not make sense to me (it is also not what 5.6 did) because some items have both "iPad Pro" and "iPhone 8" and some only have 1 of these.
I would expect that the items that have both would score higher than those that have only one. It is as if this query is acting like a filter, not scoring by similarity to the query.
What am I doing wrong?
Does anyone know if there is a new ES query form for doing this type of thing? Wow I can't believe they made this big a change -- baffling.