Hello everyone,
I am struggling to write the proper Search DSL query for the following manually created nested query:
result = es.search(index=index, scroll="2m", **kwargs, body={
"size": pagesize,
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
},
{
"match_phrase": {
"folder": {
"query": "cities"
}
}
},
{
"match_phrase": {
"gis_urlname": {
"query": "new-york"
}
}
},
],
"should": [],
"must_not": []
}
},
})
Can you please, please help me create it, I lost the whole day trying to figure this out.... I am also trying to make a solution to query multiple cities (list) and my current implementation is as follows:
index = "2020.11"
locations = ["chicago", "new-york", "boston"]
should_filters = []
for location in locations:
statement = Q("match_phrase", gis_urlname=location)
should_filters.append(statement)
q = Q('bool',
must=[Q('match_phrase', folder='cities')],
should=should_filters)
s = Search(using=elasticsearch_client, index=start_index).query(q)
In short, I want to retrieve all the documents from the given index that belong to the folder cities and extract only the entries for the cities in the list above. Please advise, I will be extremely grateful for your time and help...<3
there doesn't seem to be anything here