Filter for no nested documents

I have a mapping where we have N nested documents. Is there a way to filter
for documents which have no nested documents?
I've tried with the missinghttp://www.elasticsearch.org/guide/reference/query-dsl/missing-filter.html filter
without success.

--

I think if you wrap the nested filter in a not filter, you get what you need.

not filter:

Martijn

On 10 September 2012 10:56, Lisinge lisinge@rabble.se wrote:

I have a mapping where we have N nested documents. Is there a way to filter
for documents which have no nested documents?
I've tried with the missing filter without success.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Thanks for your reply Martijn.
I thought about that too. Could you give me an example of what you mean?

Den måndagen den 10:e september 2012 kl. 11:11:43 UTC+2 skrev Martijn v
Groningen:

I think if you wrap the nested filter in a not filter, you get what you
need.

not filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

On 10 September 2012 10:56, Lisinge <lis...@rabble.se <javascript:>>
wrote:

I have a mapping where we have N nested documents. Is there a way to
filter
for documents which have no nested documents?
I've tried with the missing filter without success.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Here is also a simple example off the mapping that is used:

{

"created_at": {
"type": "date"
},
"checkouts": {
"type": "nested",
"properties": {
"location": {
"type": "geo_point"
},
"created_at": {
"type": "date"
}
}
}

Den måndagen den 10:e september 2012 kl. 11:11:43 UTC+2 skrev Martijn v
Groningen:

I think if you wrap the nested filter in a not filter, you get what you
need.

not filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

On 10 September 2012 10:56, Lisinge <lis...@rabble.se <javascript:>>
wrote:

I have a mapping where we have N nested documents. Is there a way to
filter
for documents which have no nested documents?
I've tried with the missing filter without success.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

An example using the filtered query
(Elasticsearch Platform — Find real-time answers at scale | Elastic):
{
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"not" : {
"filter" : {
"nested" : {
"path" : "checkouts",
"query" : {
"match_all" : {}
}
}
},
"_cache" : true
}
}
}
}

The above query should return all docs that don't have nested documents.

On 10 September 2012 11:29, Lisinge lisinge@rabble.se wrote:

Here is also a simple example off the mapping that is used:

{
"created_at": {
"type": "date"
},
"checkouts": {
"type": "nested",
"properties": {
"location": {
"type": "geo_point"
},
"created_at": {
"type": "date"
}
}
}

Den måndagen den 10:e september 2012 kl. 11:11:43 UTC+2 skrev Martijn v
Groningen:

I think if you wrap the nested filter in a not filter, you get what you
need.

not filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

On 10 September 2012 10:56, Lisinge lis...@rabble.se wrote:

I have a mapping where we have N nested documents. Is there a way to
filter
for documents which have no nested documents?
I've tried with the missing filter without success.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Thanks Martijn.

I ended up with this query:
{
"filter": {
"not": {
"nested": {
"path": "checkouts",
"filter": {
"match_all": {}
}
}
}
}
}

But i believe the "match_all" is kinda misleading, is there some other way
to do it?

Den måndagen den 10:e september 2012 kl. 11:38:20 UTC+2 skrev Martijn v
Groningen:

An example using the filtered query
(
Elasticsearch Platform — Find real-time answers at scale | Elastic):

{
"filtered" : {
"query" : { "match_all" : {} },
"filter" : {
"not" : {
"filter" : {
"nested" : {
"path" : "checkouts",
"query" : {
"match_all" : {}
}
}
},
"_cache" : true
}
}
}
}

The above query should return all docs that don't have nested documents.

On 10 September 2012 11:29, Lisinge <lis...@rabble.se <javascript:>>
wrote:

Here is also a simple example off the mapping that is used:

{
"created_at": {
"type": "date"
},
"checkouts": {
"type": "nested",
"properties": {
"location": {
"type": "geo_point"
},
"created_at": {
"type": "date"
}
}
}

Den måndagen den 10:e september 2012 kl. 11:11:43 UTC+2 skrev Martijn v
Groningen:

I think if you wrap the nested filter in a not filter, you get what you
need.

not filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

On 10 September 2012 10:56, Lisinge lis...@rabble.se wrote:

I have a mapping where we have N nested documents. Is there a way to
filter
for documents which have no nested documents?
I've tried with the missing filter without success.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

--
Met vriendelijke groet,

Martijn van Groningen

--

But i believe the "match_all" is kinda misleading, is there some other way
to do it?
What do you find misleading about the "match_all"? The match all
basically selects all documents on the nested checkouts level. I think
this is the best way to do this.

--