I need to filter out documents with some kind of conditional logic (I think), but I can't get this working.
My documents are like this:
{type: 'A'}
{type: 'B', foo: ['bar']}
{type: 'B', foo: []}
Now I need to filter out all documents of type 'B' where foo is empty.
In pseudocode the query would be:
if(type == 'B' && foo == []) {
// filter out this document
}
My main query looks like this:
query: {
filtered: {
query: {
bool: {
must: {
match_all: []
}
}
},
filter: {
bool:{
must_not: {
term: {'_hidden': true}
}
}
}
}
}
Elasticsearch Version is 1.5.0
existsand/ormissingfilter. That does work for all documents of type 'B'. but it also filters all documents of type 'A', because there is never a "property" foo.