Ich habe folgende Abbildung:Filter Ergebnis mit Array von möglichen Werten
{
cities: {
mappings: {
city: {
properties: {
id: {
type: "long"
},
name: {
type: "text",
fields: {
keyword: {
type: "keyword",
ignore_above: 256
}
}
},
population: {
type: "long"
},
}
}
}
}
}
und Durchführung einfache Abfrage:
{
query: {
bool: {
must_not: { match: { name: 'New York' } },
},
},
size: 2,
}
So in den Ergebnissen, die ich erhalten:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 10385,
"max_score": 1,
"hits": [
{
"_index": "cities",
"_type": "city",
"_id": "14",
"_score": 1,
"_source": {
"name": "Berlin",
"id": 14,
"population": 7293
}
},
{
"_index": "cities",
"_type": "city",
"_id": "19",
"_score": 1,
"_source": {
"name": "Paris",
"id": 19,
"population": 25018
}
}
]
}
}
Wie kann Ich beschränke diese Abfrage auf Dokumente, in denen sich name
in einem bestimmten Array von Werten befindet, dh ['Berlin', 'Bonn', 'Munchen']
?
Ich suche nach etwas simmilar zu SQL-Anweisung:
SELECT * FROM cities WHERE name != 'New York' and name IN ('Berlin', 'Bonn', 'Munchen');
Kombinieren mit @ Lupanoides "name.keyword" macht die Arbeit. Vielen Dank! – hsz