All,
I'm stuck. We have an index of approx 100M documents with lots of
parent/child relationships. Some of our parent/child queries are
extremely slow so we wanted to look at the new nested object/query
capabilities in 0.17.1. We tried converting one of our parent/child
relationships over but couldn't ever find results. Figuring we just
had something wrong with our query generation I started putting
together a really simple example but I can't get that working either.
Can someone please help?
First, I started with a completely new elastic 0.17.1 install.
Next, create an index as follows:
curl -XPUT http://localhost:9200/echo -d '{ "settings" : { "index" :
{ "number_of_shards" : 3 } } }'
Then I loaded a simple mapping:
curl -XPUT http://localhost:9200/echo/dataset/_mapping -d '
{
"dataset": {
"properties": {
"provider_id":{"type":"string","index":"not_analyzed"},
"inner_thing" : {
"type" : "nested",
"properties" : {
"first_name" : { "type" : "string", "index" :
"not_analyzed"},
"last_name" : { "type" : "string", "index" :
"not_analyzed"}
}
}
}
}
}'
Then index a document:
curl -XPOST http://localhost:9200/_bulk -d '
{"index":{"_index":"echo","_type":"dataset","_id":"C1000000000-
PROV2"}}
{"provider_id":"PROV2", "inner_thing.first_name" : "Dan",
"inner_thing.last_name" : "Pilone"}
'
Finally, try to find it:
curl -XGET http://localhost:9200/echo/dataset/_search?pretty=true -d '
{
"query" : {
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"nested" : {
"path" : "inner_thing",
"query" : {
"bool" : {
"must" : [
{"text" : { "inner_thing.first_name" :
"Dan" }},
{"text" : { "inner_thing.last_name" :
"Pilone"}}
]
}
}
}
}
}
}
}
'
I even tried a simpler one:
curl -XGET http://localhost:9200/echo/dataset/_search?pretty=true -d '
{
"query" : {
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"nested" : {
"path" : "inner_thing",
"query" : {
"bool" : {
"must" : {
"text" : { "first_name" : "Dan" }
}
}
}
}
}
}
}
}
'
If I drop the conditions, this works:
curl -XGET http://localhost:9200/echo/dataset/_search?pretty=true -d '
{
"query" : { "match_all" : {} }
}
'
I'm stuck.... what am I missing? Thanks -- Dan