Answer the question
In order to leave comments, you need to log in
How to correctly compose a query in ElasticSearch?
My products are stored in this format in Elastica
{
"_index": "market",
"_type": "products",
"_id": "4",
"_score": 0.5619608,
"_source": {
"id": 4,
"title": "Zora",
"category_id": 3,
"price": "35000.00",
"characteristicValue": [
{
"id": 1,
"name": "Красный",
"characteristic": {
"id": 2,
"name": "color"
}
}
]
}
}
"query": {
"bool": {
"must": [
{"match": {
"characteristicValue.characteristic.name": "color"
}}
],
"should": [
{"terms": {
"characteristicValue.name": [
"красный",
"синий"
]
}}
]
}
}
Answer the question
In order to leave comments, you need to log in
what should be moved to must
https://www.elastic.co/guide/en/elasticsearch/ref...
If the bool query is in a query context and has a must or filter clause then a document will match the bool query even if none of the should queries match . In this case these clauses are only used to influence the score .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question