Hello,
We are evaluating Lucene and in particular Elastic Search to see whether we can replace our existing search engine. One feature it has, which we use, is that it understands hierarchy in content. ElasticSearch has the beginning of similar support, but it looks like it's lacking a way to express certain queries.
An example says more than a thousand words. Below I add two documents representing families and their cars. Neither family owns a gray Toyota, yet both families are returned. The query is missing the constraint that car.make and car.color aren't independent, but should refer to the same car. In the other product, the query would look like:
(((Toyota <IN> make) <AND> (gray <IN> color)) <IN> car)
Would it be possible to add a similar feature to ElasticSearch?
I'm not aware that it's ever been done in a Lucene-based product. This mail to the Solr mailinglist shows how you could index the data such that it becomes possible to query the hierarchy, but care is needed because it uses a concatenation of two fields into one.
Thanks for a very exciting product and thanks or listening,
Regards,
Bart Schuller.
Here's the example as three shell statements:
curl -XPUT 'http://localhost:9200/zonetest/family/1' -d '
{
"name": "Jones",
"car": [
{
"make": "Toyota",
"color": "green"
},
{
"make": "Ford",
"color": "gray"
}
]
}
'
curl -XPUT 'http://localhost:9200/zonetest/family/2' -d '
{
"name": "Gates",
"car": [
{
"make": "Rolls-Royce",
"color": "gray"
},
{
"make": "Toyota",
"color": "blue"
}
]
}
'
curl -XGET 'http://localhost:9200/zonetest/family/_search' -d '
{
"query" : {
"bool" : {
"must" : [
{
"field" : { "car.make" : "Toyota" }
},
{
"field" : { "car.color" : "gray" }
}
]
}
}
}
'