Hello everyone,
I have a field
"language" that might contain values in any kind of ordering (example: "[de, en, fr]" or "[en]" or "[fr, de, en]"
I need to filter by "language: (en and minimum one more language)".
Any ideas please?
Hello everyone,
I have a field
"language" that might contain values in any kind of ordering (example: "[de, en, fr]" or "[en]" or "[fr, de, en]"
I need to filter by "language: (en and minimum one more language)".
Any ideas please?
Hey @Smoerble_Smorebrod, what do the Elasticsearch mappings look like for the field you're looking to filter on?
If you create an index with a field-type of keyword
:
PUT smoe
{
"mappings": {
"properties": {
"language": {
"type": "keyword"
}
}
}
}
And index a document into it, you can include multiple values for that field:
POST smoe/_doc
{
"language": ["fr", "en", "de"]
}
You can then search en
and one more language using the following:
POST smoe/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"language": "en"
}
},
{
"terms": {
"language": [
"fr",
"de"
]
}
}
]
}
}
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.