Damn...
I tried also your way, it works...
The problem is in my mapping i guess. I declared seller and address as
'nested' type field instead of object.
[...]
.startObject("seller")
-
.field("type", "nested")*
.startObject("properties")
.startObject("seller_id")
.field("type", "string")
.field("store", "yes")
.field("index", "not_analyzed")
.endObject()
.startObject("address")
* .field("type", "nested")*
.startObject("properties")
.startObject("department")
.field("type", "integer")
.field("store", "no")
.field("index", "analyzed")
.field("search_analyzer",
"items_search_analyzer")
.field("index_analyzer",
"items_index_analyzer")
.endObject()
.startObject("city")
.field("type", "string")
.field("store","no")
.field("index", "analyzed")
.field("search_analyzer",
"items_search_analyzer")
.field("index_analyzer",
"items_index_analyzer")
.endObject()
.startObject("location")
.field("type", "geo_point")
.field("lat_lon", true)
.endObject()
.startObject("country")
[...]
If i replace the nested type by object type, it works.
[...]
.startObject("seller")
I saw the "type", "nested" way of mapping nested objects in elasticsearch
integration tests.
client.admin().indices().prepareCreate("test")
.addMapping("type1",
jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("nested1")
.field("type", "nested")
.endObject()
.endObject().endObject().endObject())
.execute().actionGet();
(Cf.
https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java
)
Is the nested type not suitable for (geoloc) search ?
On Wed, Jan 9, 2013 at 12:29 PM, Igor Motov imotov@gmail.com wrote:
If distance is correct, it works for me:
https://groups.google.com/d/topic/elasticsearch/9hJzp_cAnuo/discussion · GitHub
On Wednesday, January 9, 2013 4:11:47 AM UTC-5, Frederic Esnault wrote:
Yes i almost added something to tell you not to take this distance into
consideration.
I DO have some items very close to my searched geopoint. That's why i get
results when location is not nested.
Sorry i should have told it was just a document structure example, and
not the only data in my index.
On Wed, Jan 9, 2013 at 12:59 AM, Igor Motov imo...@gmail.com wrote:
The distance between location in your query and location in the seller
address is close to 600km. So, you shouldn't get this record back.
On Tuesday, January 8, 2013 12:05:57 PM UTC-5, Frederic Esnault wrote:
Hi all,
I have a strange problem with geo_distance filtered query.
Say i have a document like this :
{
model: Samsung Galaxy S III
pvttc: 350
location: {
lat: 44.5688896
lon: 6.100903
}
seller: {
id: 5126
address: {
department: 05
city: GAP
country: FR
}
}
}
When i query for items close to a lon/lat pair, it works this way :
{
"query" :
{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "5km",
"location" : {
"lat" : 49.00331,
"lon" : 2.0834715
}
}
}
}
}
}
I get my results.
But say my doc is like this :
{
model: Samsung Galaxy S III
pvttc: 350
seller: {
id: 5126
address: {
department: 05
city: GAP
country: FR
location: {
lat: 44.5688896
lon: 6.100903
}
}
}
}
(note the location is nested under seller.address.)
I can't get my results if i query this way :
{
"query" :
{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "5km",
"seller.address.location" : {
"lat" : 49.00331,
"lon" : 2.0834715
}
}
}
}
}
}
No hits. Same data (except for mapping, which has been updated (index
deleted, mapping changed, and data reindexed with the location moved to its
nested position).
If i query for a seller.addres.geoloc (wrong field name), i get an
error, so it actually finds the seller.address.location field, but seems
not to work.
Any idea ?
--
--
--