Querying for documents which do not contain an element in an array field

Suppose I have a document with a "tags" field which is an array (just
as here http://www.elasticsearch.org/guide/reference/mapping/array-type.html)

Is it possible to query for documents do not contain a given tag?

Thanks,
Adam

Hi Adam

On Wed, 2011-05-04 at 02:20 -0700, Adam Warski wrote:

Suppose I have a document with a "tags" field which is an array (just
as here Elasticsearch Platform — Find real-time answers at scale | Elastic)

Is it possible to query for documents do not contain a given tag?

curl -XGET 'http://127.0.0.1:9200/myindex/mytype/_search?pretty=1' -d '
{
"query" : {
"constant_score" : {
"filter" : {
"not" : {
"filter" : {
"term" : {
"tags" : "foo"
}
}
}
}
}
}
}
'

Ah, so simple, thanks! :slight_smile:

Adam

On May 4, 11:27 am, Clinton Gormley clin...@iannounce.co.uk wrote:

Hi Adam

On Wed, 2011-05-04 at 02:20 -0700, Adam Warski wrote:

Suppose I have a document with a "tags" field which is an array (just
as herehttp://www.elasticsearch.org/guide/reference/mapping/array-type.html)

Is it possible to query for documents do not contain a given tag?

curl -XGET 'http://127.0.0.1:9200/myindex/mytype/_search?pretty=1' -d '
{
"query" : {
"constant_score" : {
"filter" : {
"not" : {
"filter" : {
"term" : {
"tags" : "foo"
}
}
}
}
}
}}

'