Filter/match/return nested objects

Hi all,

I have a question on ES use.

We assume that in our schema we have a user that has many posts. We want to
search if the title or the description of a user's post contains a word and
return those posts.
Is it something doable with ES?

My try is:

{
"query" : {
"nested" : {
"path" : "posts",
"query" : {
"multi_match" : {
"query" :'foo',
"fields" : [ "posts.title", "posts.description" ]
}
}
}
}
}

However the above returns the whole user document (/object) once the
multi_match criteria are true and not filtering each post in posts. I tried
the same with nested as filter but I not much of a difference.

Thanks,
D

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/028bd42a-3bb8-4c16-ade9-1d1f5b32259e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

My first thought about it is that if you are searching for posts then index posts!
A posts can contain many attributes such as the user who wrote the post.

{
"content" :"my text here",
"user": {
"login": "mylogin",
"twitter":"myaccount"
}
}

What do you think? Could it help you to design your documents?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 27 novembre 2013 at 23:16:57, Dionysis Lorentzos (ddl449@gmail.com) a écrit:

Hi all,

I have a question on ES use.

We assume that in our schema we have a user that has many posts. We want to search if the title or the description of a user's post contains a word and return those posts.
Is it something doable with ES?

My try is:

{
"query" : {
"nested" : {
"path" : "posts",
"query" : {
"multi_match" : {
"query" :'foo',
"fields" : [ "posts.title", "posts.description" ]
}
}
}
}
}

However the above returns the whole user document (/object) once the multi_match criteria are true and not filtering each post in posts. I tried the same with nested as filter but I not much of a difference.

Thanks,
D

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/028bd42a-3bb8-4c16-ade9-1d1f5b32259e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.5296704b.2901d82.3e14%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

If I understand your issue correctlu, that feature is not yet supported:

Cheers,

Ivan

On Wed, Nov 27, 2013 at 2:20 PM, David Pilato david@pilato.fr wrote:

My first thought about it is that if you are searching for posts then
index posts!
A posts can contain many attributes such as the user who wrote the post.

{
"content" :"my text here",
"user": {
"login": "mylogin",
"twitter":"myaccount"
}
}

What do you think? Could it help you to design your documents?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 27 novembre 2013 at 23:16:57, Dionysis Lorentzos (ddl449@gmail.com//ddl449@gmail.com)
a écrit:

Hi all,

I have a question on ES use.

We assume that in our schema we have a user that has many posts. We want
to search if the title or the description of a user's post contains a word
and return those posts.
Is it something doable with ES?

My try is:

{
"query" : {
"nested" : {
"path" : "posts",
"query" : {
"multi_match" : {
"query" :'foo',
"fields" : [ "posts.title", "posts.description" ]
}
}
}
}
}

However the above returns the whole user document (/object) once the
multi_match criteria are true and not filtering each post in posts. I tried
the same with nested as filter but I not much of a difference.

Thanks,
D

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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/028bd42a-3bb8-4c16-ade9-1d1f5b32259e%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/etPan.5296704b.2901d82.3e14%40MacBook-Air-de-David.local
.

For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAegiaSOLGMsrzuJT9omhSR1HD1G-sjzRgx-_72CKfuRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David and Ivan,

Well my data source is a MongoDB using Richard's river plugin[1].

So afaik, since I have a mongo collection of users it's not possible to
index nested fields, or is it?

In practice I have:
http://localhost:9200/database/users/_mapping/ which gives:

{
user : {
name: {
type: "string"
},
posts : {
type: "nested",
properties: {
title: {
type: "string"
},
description: {
type: "string"
}
}
}
}
}

but this cannot be done:

http://localhost:9200/database/users/posts/_mapping

as I get "No handler found for uri".

I think as Ivan posted, is not yet supported unless there is a workaround.
Best,
D

[1] GitHub - richardwilly98/elasticsearch-river-mongodb: MongoDB River Plugin for ElasticSearch

On Thursday, November 28, 2013 12:33:25 AM UTC+2, Ivan Brusic wrote:

If I understand your issue correctlu, that feature is not yet supported:
Return matching nested inner objects per hit · Issue #3022 · elastic/elasticsearch · GitHub

Cheers,

Ivan

On Wed, Nov 27, 2013 at 2:20 PM, David Pilato <da...@pilato.fr<javascript:>

wrote:

My first thought about it is that if you are searching for posts then
index posts!
A posts can contain many attributes such as the user who wrote the post.

{
"content" :"my text here",
"user": {
"login": "mylogin",
"twitter":"myaccount"
}
}

What do you think? Could it help you to design your documents?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 27 novembre 2013 at 23:16:57, Dionysis Lorentzos (ddl...@gmail.com<javascript:>)
a écrit:

Hi all,

I have a question on ES use.

We assume that in our schema we have a user that has many posts. We want
to search if the title or the description of a user's post contains a word
and return those posts.
Is it something doable with ES?

My try is:

{
"query" : {
"nested" : {
"path" : "posts",
"query" : {
"multi_match" : {
"query" :'foo',
"fields" : [ "posts.title", "posts.description" ]
}
}
}
}
}

However the above returns the whole user document (/object) once the
multi_match criteria are true and not filtering each post in posts. I tried
the same with nested as filter but I not much of a difference.

Thanks,
D

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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/028bd42a-3bb8-4c16-ade9-1d1f5b32259e%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/etPan.5296704b.2901d82.3e14%40MacBook-Air-de-David.local
.

For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0424de6e-b050-4461-a3f8-286d4299bbe0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.