AWS tarafından yönetilen Elasticsearch hizmetini kullanıyoruz ve yakın zamanda 1,5'ten 2,3'e yükseltildi. Sorgularımızı oluşturmak için python'daki elasticsearch-dsl paketini kullanıyoruz ve sorgularımızın çoğunu taşımayı başardık, ancak ne yaptığım önemli değil, geo_distance bozuk.Elasticsearch'e güncelledikten sonra iç içe geçmiş geopoint bulunamıyor 2.3
Haritalama:
{
'company': {
'properties': {
'id': {'type': 'integer'},
'company_number': {'type': 'string'},
'addresses': {
'type': 'nested',
'properties': {
'postcode': {'type': 'string', 'index': 'not_analyzed'},
'location': {'type': 'geo_point'}
}
}
}
}
}
elasticsearch-dsl == ile kütüphanesi tarafından oluşturulan 0.0.11
test_location = '53.5411062377, -2.11485504709'
test_distance = "3miles"
location_filter = F("geo_distance",
location=test_location,
distance=test_distance)
query = query.filter("nested",
path="addresses",
filter=location_filter)
Sorgu çalışma
Python kodu :
{'query': {'filtered': {'filter': {'nested': {'filter': {'geo_distance': {'distance': u'3miles', 'location': '53.5411062377, -2.11485504709'}}, 'path': 'addresses'}}, 'query': {'match_all': {}}}}}
Biz bir marka yarattık Aynı eşleme ile yeni bir 2.3 yeni dizin.
== 2.1.0-dsl elasticsearch geçmenizi ve sorguları için filtreleri dönüştürmek denemeden sonra: aşağıdaki sorguyu üretir
geo_query = Q({"bool": {
"must": [
{
"geo_distance": {
"distance": "test_distance",
"addresses__location": test_location,
}
},
]
}})
:
{'query': {'bool': {'must': [{'geo_distance': {'distance': '3 miles', u'addresses.location': {'lat': '53.5411062377', 'lon': '-2.11485504709'}}}]}}}
Biz şu istisna olsun:
RequestError: TransportError(400, u'search_phase_execution_exception', u'failed to find geo_point field [addresses.location]')
Alana "konum", "adres.location", "ad" olarak başvurmayı denedim elbiseler 've eski iç içe geçmiş sorgu türünü kullanarak. Eşlemenin 2.3'te artık geçerli olmadığını veya sorguyu yanlış oluşturuyorsam anlamıyorum. Ben lat_lon eklemek gerektiğini düşünüyorum
RequestError: TransportError(400, u'search_phase_execution_exception', u'[nested] nested object under path [addresses.location] is not of nested type')
:
sorgu
Q({'nested': {'filter': {
'geo_distance': {'distance': u'3miles', 'location': '53.5411062377, -2.11485504709'}
},
'path': 'addresses.location'}})
aşağıdaki hatayı üretir geodistance sorguları çalışması için haritalama Doğru, ama örneklerin hiçbiri ona sahip .
Herhangi bir yardım çok takdir edilecektir, teşekkür ederim!
'path'' addresses' olmalı ve 'geo_distance' filtresinde yerine sadece' "konumunun" ' "addresses.location"' 'olmalıdır – Val
Üzgünüm Bunu '.location' ile birlikte denediniz. – marklar
Aşağıdaki cevabı deneyebilir misiniz? – Val