Having the following dataset:
[
{
"id": 234,
"category": "shoe"
},
{
"id": 44,
"category": "shoes"
},
{
"id": 49,
"category": "blue shoes"
},
{
"id": 48,
"category": "small shoes with glare"
}
]
Category's mapping is set to text.
And making a query like:
$query = (new ElasticQuery())
->setQuery([
"bool" => [
"must" => [
"match" => [
"category" => [
"query" => "shoe size 22"
],
]
]
],
]);
Elastic always returns me as first results/highest score:
- small shoes with glare
- blue shoes
- shoes
Rather than shoe.
How can i tell elastic that i only want documents whose match is 100% of category's content? (not query)
I mean, if my search doesn't contain "blue shoes", i don't want blue result to appear. I only expected to get shoe or shoe and shoes at max.
I can't use term, because as i said, i don't expect a full match with the query. I expect the matched documents field to be fully matched.
Examples:
- Query: shoe size 22
- Expected results:
- shoe
- Query: small shoes with glare
- Expected results:
- small shoes with glare
- shoes
- Query: blue shoes
- Expected results:
- blue shoes
- shoes
- Query: green shoes
- Expected results:
- shoes