We are having a beast of a time trying to figure this one out.
We have a document structure where we are using nested "keywords" documents
to model arbitrary metadata in what I guess would be called an
overnormalized schema...
{
"keywords": [
{"field": "foo", "value": "abc"},
{"field": "bar", "value": "def"}
]
}
I'm looking for a query that will return the above document via the logic
expressed in the following pseudo-query: return all documents that contain
2 keywords children WHERE one of them has (keywords.field "foo" with value
"abc") AND the other one has (keywords.field "bar" with value "def").
I'm hoping I'm missing something fundamental and simple (would a "must"
query somehow help?), but it appears this is not very easy to accomplish.
This is the closest we can get with our burgeoning understanding of ES
queries (coming from vanilla Lucene background)...
{
"query": {
"filtered": {
"query": { "match_all": {}},
"filter": {
"and": [
{
"nested": {
"path": "keywords",
"query": {
"query_string": "keywords.field:foo AND
keywords.value:abc"
}
}
},
{
"nested": {
"path": "keywords",
"query": {
"query_string": "keywords.field:bar AND
keywords.value:def"
}
}
}
]
}
}
}
}
Removing one or the other of the nested queries does, of course, return the
document, but using them both results in 0 documents where I expect 1.
I can almost see why the above query won't work, but what I can't see if
the way to change it into something that will work. Any help is very much
appreciated.
--
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.
For more options, visit https://groups.google.com/groups/opt_out.