Nested type definition & cross document matching

I posted the following document to elastic search.

{
"car": {
"name": "Honda City",
"model": "2013"
},
"inventory": [
{
"zipcode": "02115",
"mileage": "10000",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "13210",
"mileage": "10000",
"city": "Syracuse"
}
]
}

I did not define any mapping. So I was assuming that the filtering for "zipcode" : "10000" AND "mileage":89 would return the above document as a hit. But it doesnt. Following is my query

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"location.mileage": "89"
}
},
{
"term": {
"location.zipcode": "13210"
}
}
]
}
}

In other words, cross document matching doesnt occur when I dont define the location field as nested. Is my understanding correct?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e688f2a9-255b-4eaa-99f6-e954974ab9d6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

you should search for inventory.mileage and inventory.zipcode I guess

--Alex

On Sat, Dec 7, 2013 at 10:52 AM, dsk karthick.soundararaj@gmail.com wrote:

I posted the following document to Elasticsearch.

{
"car": {
"name": "Honda City",
"model": "2013"
},
"inventory": [
{
"zipcode": "02115",
"mileage": "10000",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "13210",
"mileage": "10000",
"city": "Syracuse"
}
]
}

I did not define any mapping. So I was assuming that the filtering for "zipcode" : "10000" AND "mileage":89 would return the above document as a hit. But it doesnt. Following is my query

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"location.mileage": "89"
}
},
{
"term": {
"location.zipcode": "13210"
}
}
]
}
}

In other words, cross document matching doesnt occur when I dont define the location field as nested. Is my understanding correct?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e688f2a9-255b-4eaa-99f6-e954974ab9d6%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_QaKcGUjErbvKfWdw1Rs6khHnZppBcv43k%2BhfOYvD1%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

My bad. I should have changed that. Following query doesnt return any
result either.

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"inventory.mileage": "89"
}
},
{
"term": {
"inventory.zipcode": "13210"
}
}
]
}
}

On Sat, Dec 7, 2013 at 7:11 AM, Alexander Reelsen alr@spinscale.de wrote:

Hey,

you should search for inventory.mileage and inventory.zipcode I guess

--Alex

On Sat, Dec 7, 2013 at 10:52 AM, dsk karthick.soundararaj@gmail.comwrote:

I posted the following document to Elasticsearch.

{
"car": {
"name": "Honda City",
"model": "2013"
},
"inventory": [
{
"zipcode": "02115",
"mileage": "10000",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "13210",
"mileage": "10000",
"city": "Syracuse"
}
]
}

I did not define any mapping. So I was assuming that the filtering for "zipcode" : "10000" AND "mileage":89 would return the above document as a hit. But it doesnt. Following is my query

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"location.mileage": "89"
}
},
{
"term": {
"location.zipcode": "13210"
}
}
]
}
}

In other words, cross document matching doesnt occur when I dont define the location field as nested. Is my understanding correct?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e688f2a9-255b-4eaa-99f6-e954974ab9d6%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_8_lgike3Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_QaKcGUjErbvKfWdw1Rs6khHnZppBcv43k%2BhfOYvD1%3Dw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CABKv5CJyHkoycQZ%2Bdp59jb4mo62oqSpemhXAzauXRi6UCqKTAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

can you create a gist with all the curl commands you entered (index
creation, mapping, query) and specify the elasticsearch version you are
using? This works for me, but might be different to your example (tested
with 1.0.0 beta2) - maybe I misread something

curl -X PUT 'localhost:9200/test/test/1?refresh' -d '
{
"inventory": [
{
"zipcode": "02115",
"mileage": "89"
},
{
"zipcode": "13210",
"mileage": "10000"
}
]
}
'

curl -X POST 'localhost:9200/test/test/_search' -d '{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"inventory.mileage": "89"
}
},
{
"term": {
"inventory.zipcode": "13210"
}
}
]
}
}'

--Alex

On Sat, Dec 7, 2013 at 7:05 PM, Karthick Duraisamy Soundararaj <
karthick.soundararaj@gmail.com> wrote:

My bad. I should have changed that. Following query doesnt return any
result either.

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"inventory.mileage": "89"
}
},
{
"term": {
"inventory.zipcode": "13210"
}
}
]
}
}

On Sat, Dec 7, 2013 at 7:11 AM, Alexander Reelsen alr@spinscale.dewrote:

Hey,

you should search for inventory.mileage and inventory.zipcode I guess

--Alex

On Sat, Dec 7, 2013 at 10:52 AM, dsk karthick.soundararaj@gmail.comwrote:

I posted the following document to Elasticsearch.

{
"car": {
"name": "Honda City",
"model": "2013"
},
"inventory": [
{
"zipcode": "02115",
"mileage": "10000",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "13210",
"mileage": "10000",
"city": "Syracuse"
}
]
}

I did not define any mapping. So I was assuming that the filtering for "zipcode" : "10000" AND "mileage":89 would return the above document as a hit. But it doesnt. Following is my query

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"location.mileage": "89"
}
},
{
"term": {
"location.zipcode": "13210"
}
}
]
}
}

In other words, cross document matching doesnt occur when I dont define the location field as nested. Is my understanding correct?

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e688f2a9-255b-4eaa-99f6-e954974ab9d6%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_8_lgike3Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_QaKcGUjErbvKfWdw1Rs6khHnZppBcv43k%2BhfOYvD1%3Dw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CABKv5CJyHkoycQZ%2Bdp59jb4mo62oqSpemhXAzauXRi6UCqKTAQ%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-mpVJHGv5ndnLQaDTLsZWzs1_cW79cMASnCXwNqofE5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

I tried you commands and it seems works as expected now. Thanks Alex.

Reg my earlier wierd behaviour, I had two indexes cars and cars1. I defined
inventory as a nested type for cars index type but did not define any
mapping for cars1

So could it be that the mapping for cars was used cars1?

On Sat, Dec 7, 2013 at 10:18 AM, Alexander Reelsen alr@spinscale.de wrote:

Hey,

can you create a gist with all the curl commands you entered (index
creation, mapping, query) and specify the elasticsearch version you are
using? This works for me, but might be different to your example (tested
with 1.0.0 beta2) - maybe I misread something

curl -X PUT 'localhost:9200/test/test/1?refresh' -d '
{
"inventory": [
{
"zipcode": "02115",
"mileage": "89"
},
{
"zipcode": "13210",
"mileage": "10000"
}
]
}
'

curl -X POST 'localhost:9200/test/test/_search' -d '{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"inventory.mileage": "89"
}
},
{
"term": {
"inventory.zipcode": "13210"
}
}
]
}
}'

--Alex

On Sat, Dec 7, 2013 at 7:05 PM, Karthick Duraisamy Soundararaj <
karthick.soundararaj@gmail.com> wrote:

My bad. I should have changed that. Following query doesnt return any
result either.

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"inventory.mileage": "89"
}
},
{
"term": {
"inventory.zipcode": "13210"
}
}
]
}
}

On Sat, Dec 7, 2013 at 7:11 AM, Alexander Reelsen alr@spinscale.dewrote:

Hey,

you should search for inventory.mileage and inventory.zipcode I guess

--Alex

On Sat, Dec 7, 2013 at 10:52 AM, dsk karthick.soundararaj@gmail.comwrote:

I posted the following document to Elasticsearch.

{
"car": {
"name": "Honda City",
"model": "2013"
},
"inventory": [
{
"zipcode": "02115",
"mileage": "10000",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "02115",
"mileage": "89",
"city": "Boston"
},
{
"zipcode": "13210",
"mileage": "10000",
"city": "Syracuse"
}
]
}

I did not define any mapping. So I was assuming that the filtering for "zipcode" : "10000" AND "mileage":89 would return the above document as a hit. But it doesnt. Following is my query

{
"query": {
"match_all": {

}

},
"filter": {
"and": [
{
"term": {
"location.mileage": "89"
}
},
{
"term": {
"location.zipcode": "13210"
}
}
]
}
}

In other words, cross document matching doesnt occur when I dont define the location field as nested. Is my understanding correct?

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e688f2a9-255b-4eaa-99f6-e954974ab9d6%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_8_lgike3Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_QaKcGUjErbvKfWdw1Rs6khHnZppBcv43k%2BhfOYvD1%3Dw%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CABKv5CJyHkoycQZ%2Bdp59jb4mo62oqSpemhXAzauXRi6UCqKTAQ%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/_8_lgike3Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-mpVJHGv5ndnLQaDTLsZWzs1_cW79cMASnCXwNqofE5Q%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CABKv5CJX6jcZAOb3a%2BOLVJLpRGMyAJ9--%3DnLBKuU3Fia%3DjEwLg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.