Nested match must_not filter doesnot work

All,

I'm trying to run a must_not filter wrapped in bool

My Mappings
{
"response": {
"properties": {
"rtext": {
"type": "nested",
"properties": {
"textmapid": {
"type": "integer"
},
"textvalue": {
"type": "string"
}
}
}
}
}
}

Sample data

{
"rtext" : [
{
"textmapid" : 1,
"textvalue" : "Jennifer"
},
{
"textmapid" : 2,
"textvalue" : "Adam"
}
]
}

My Query comes back with hits.

{
"filter": {
"nested": {
"path": "rtext",
"query": {
"bool": {
"must_not": [
{
"match": {
"rtext.textvalue": "Jennifer"
}
},
{
"term": {
"rtext.textmapid": 1
}
}
]
}
}
}
}
}

Any help is appreciated,
Abhishek

--
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.

Your query seems to work as expected. You have two nested documents and
your query inside nested query doesn't match the first one but it matches
the second one, so you get this record returned. If you don't want a
document to be returned if at least one of its nested documents matches,
you need to move must_not outside of nested:

{
"filter": {
"bool": {
"must_not": [{
"nested": {
"path": "rtext",
"query": {
"bool": {
"must": [{
"match": {
"rtext.textvalue": "Jennifer"
}
}, {
"term": {
"rtext.textmapid": 1
}
}]
}
}
}
}]
}
}
}

On Tuesday, August 13, 2013 5:36:11 PM UTC-4, Abhishek Andhavarapu wrote:

All,

I'm trying to run a must_not filter wrapped in bool

My Mappings
{
"response": {
"properties": {
"rtext": {
"type": "nested",
"properties": {
"textmapid": {
"type": "integer"
},
"textvalue": {
"type": "string"
}
}
}
}
}
}

Sample data

{
"rtext" : [
{
"textmapid" : 1,
"textvalue" : "Jennifer"
},
{
"textmapid" : 2,
"textvalue" : "Adam"
}
]
}

My Query comes back with hits.

{
"filter": {
"nested": {
"path": "rtext",
"query": {
"bool": {
"must_not": [
{
"match": {
"rtext.textvalue": "Jennifer"
}
},
{
"term": {
"rtext.textmapid": 1
}
}
]
}
}
}
}
}

Any help is appreciated,
Abhishek

--
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.

1 Like