Join kind of query

Hello,
In one index I have 3 different types of documents. One, has IDs of
other two.
For example:
Type 1:
{ "post":{
"properties":{
"postId":{"type":"string", index:"not_analyzed"},
"description":{"type":"string"},
"categoryId":{"type":"string", index:"not_analyzed"},
"userId":{"type":"string", index:"not_analyzed"},
} } }

Type 2:
{ "user":{
"properties":{
"userId":{"type":"string", index:"not_analyzed"},
"screenName":{"type":"string", index:"not_analyzed"},
} } }

Type 3:
{ "category":{
"properties":{
"categoryId":{"type":"string", index:"not_analyzed"},
"categoryName":{"type":"string", index:"not_analyzed"},
} } }

Currently I make 2 requests, one for the post, and the second one for
the user and category.
Could I get everything at once from a single request?

Thank you,
Eugene S.

Perhaps a stupid answer but why don't you index the post with the full content (author and category) ?

Seems like you are doing YesSql...

BTW, a better answer is perhaps : "have a look at the parent/child feature".

I don't use it myself but I think it can do what you want to do.

HTH,
David :wink:
@dadoonet

Le 27 nov. 2011 à 02:24, Eugene Strokin eugene@strokin.info a écrit :

Hello,
In one index I have 3 different types of documents. One, has IDs of
other two.
For example:
Type 1:
{ "post":{
"properties":{
"postId":{"type":"string", index:"not_analyzed"},
"description":{"type":"string"},
"categoryId":{"type":"string", index:"not_analyzed"},
"userId":{"type":"string", index:"not_analyzed"},
} } }

Type 2:
{ "user":{
"properties":{
"userId":{"type":"string", index:"not_analyzed"},
"screenName":{"type":"string", index:"not_analyzed"},
} } }

Type 3:
{ "category":{
"properties":{
"categoryId":{"type":"string", index:"not_analyzed"},
"categoryName":{"type":"string", index:"not_analyzed"},
} } }

Currently I make 2 requests, one for the post, and the second one for
the user and category.
Could I get everything at once from a single request?

Thank you,
Eugene S.

Guilty as charged,.. looks like I need to review my strategy to get
back to NoSQL :slight_smile:
In "post" I cannot index full content, because if categoryName will be
updated, I'll need to update all posts from that category, and it
could be thousands of them.
Thanks for the link, I'll try to play with parent/child feature, I
don't really understand how it works yet, but it looks promising. Only
one concern I have right away, that I would need 2 parents for my
posts, one for category and one for user, but may be it supports deep
nesting, so my posts would have category as a parent, and category
could have user as a parent.
If someone has any suggestion, I'd greatly appreciate them, as well as
any info related to the problem.
Thanks in advance,
Eugene S.

On Nov 26, 10:40 pm, David Pilato da...@pilato.fr wrote:

Perhaps a stupid answer but why don't you index the post with the full content (author and category) ?

Seems like you are doing YesSql...

BTW, a better answer is perhaps : "have a look at the parent/child feature".Elasticsearch Platform — Find real-time answers at scale | Elastic

I don't use it myself but I think it can do what you want to do.

HTH,
David :wink:
@dadoonet

Le 27 nov. 2011 à 02:24, Eugene Strokin eug...@strokin.info a écrit :

Hello,
In one index I have 3 different types of documents. One, has IDs of
other two.
For example:
Type 1:
{ "post":{
"properties":{
"postId":{"type":"string", index:"not_analyzed"},
"description":{"type":"string"},
"categoryId":{"type":"string", index:"not_analyzed"},
"userId":{"type":"string", index:"not_analyzed"},
} } }

Type 2:
{ "user":{
"properties":{
"userId":{"type":"string", index:"not_analyzed"},
"screenName":{"type":"string", index:"not_analyzed"},
} } }

Type 3:
{ "category":{
"properties":{
"categoryId":{"type":"string", index:"not_analyzed"},
"categoryName":{"type":"string", index:"not_analyzed"},
} } }

Currently I make 2 requests, one for the post, and the second one for
the user and category.
Could I get everything at once from a single request?

Thank you,
Eugene S.

This is about the same use case I have at work.
To be honest, I don't know yet how I will handle it. By now, I reindex every content that has been updated.

I'm wondering how I should store my documents in CouchDb and how I will update them... Perhaps, get all documents, change the value and push it again to CouchDb ? Looks like reindexing...

BTW, I don't think you can have two parents with ES as the API doesn't seem to support it.

David :wink:
@dadoonet

Le 27 nov. 2011 à 06:37, Eugene Strokin eugene@strokin.info a écrit :

Guilty as charged,.. looks like I need to review my strategy to get
back to NoSQL :slight_smile:
In "post" I cannot index full content, because if categoryName will be
updated, I'll need to update all posts from that category, and it
could be thousands of them.
Thanks for the link, I'll try to play with parent/child feature, I
don't really understand how it works yet, but it looks promising. Only
one concern I have right away, that I would need 2 parents for my
posts, one for category and one for user, but may be it supports deep
nesting, so my posts would have category as a parent, and category
could have user as a parent.
If someone has any suggestion, I'd greatly appreciate them, as well as
any info related to the problem.
Thanks in advance,
Eugene S.

On Nov 26, 10:40 pm, David Pilato da...@pilato.fr wrote:

Perhaps a stupid answer but why don't you index the post with the full content (author and category) ?

Seems like you are doing YesSql...

BTW, a better answer is perhaps : "have a look at the parent/child feature".Elasticsearch Platform — Find real-time answers at scale | Elastic

I don't use it myself but I think it can do what you want to do.

HTH,
David :wink:
@dadoonet

Le 27 nov. 2011 à 02:24, Eugene Strokin eug...@strokin.info a écrit :

Hello,
In one index I have 3 different types of documents. One, has IDs of
other two.
For example:
Type 1:
{ "post":{
"properties":{
"postId":{"type":"string", index:"not_analyzed"},
"description":{"type":"string"},
"categoryId":{"type":"string", index:"not_analyzed"},
"userId":{"type":"string", index:"not_analyzed"},
} } }

Type 2:
{ "user":{
"properties":{
"userId":{"type":"string", index:"not_analyzed"},
"screenName":{"type":"string", index:"not_analyzed"},
} } }

Type 3:
{ "category":{
"properties":{
"categoryId":{"type":"string", index:"not_analyzed"},
"categoryName":{"type":"string", index:"not_analyzed"},
} } }

Currently I make 2 requests, one for the post, and the second one for
the user and category.
Could I get everything at once from a single request?

Thank you,
Eugene S.

In Solr I did the same, just stored everything in a post document, and
reindex all posts, if category or user name changed. I was hoping in
ES I could do this more efficient. But looks like Parent/Child feature
also wouldn't help, because it allows to search on child but return
parent. But in my case I need to search on children and parents, and
get all children with it's parents together.
Well, I'll play with it little bit more, and if nothing is found will
get back to reindexing all posts.
Will keep you posted, looks like this is not only my problem, people
could get such use cases in their projects))

On Nov 27, 2:40 am, David Pilato da...@pilato.fr wrote:

This is about the same use case I have at work.
To be honest, I don't know yet how I will handle it. By now, I reindex every content that has been updated.

I'm wondering how I should store my documents in CouchDb and how I will update them... Perhaps, get all documents, change the value and push it again to CouchDb ? Looks like reindexing...

BTW, I don't think you can have two parents with ES as the API doesn't seem to support it.

David :wink:
@dadoonet

Le 27 nov. 2011 à 06:37, Eugene Strokin eug...@strokin.info a écrit :

Guilty as charged,.. looks like I need to review my strategy to get
back to NoSQL :slight_smile:
In "post" I cannot index full content, because if categoryName will be
updated, I'll need to update all posts from that category, and it
could be thousands of them.
Thanks for the link, I'll try to play with parent/child feature, I
don't really understand how it works yet, but it looks promising. Only
one concern I have right away, that I would need 2 parents for my
posts, one for category and one for user, but may be it supports deep
nesting, so my posts would have category as a parent, and category
could have user as a parent.
If someone has any suggestion, I'd greatly appreciate them, as well as
any info related to the problem.
Thanks in advance,
Eugene S.

On Nov 26, 10:40 pm, David Pilato da...@pilato.fr wrote:

Perhaps a stupid answer but why don't you index the post with the full content (author and category) ?

Seems like you are doing YesSql...

BTW, a better answer is perhaps : "have a look at the parent/child feature".Elasticsearch Platform — Find real-time answers at scale | Elastic

I don't use it myself but I think it can do what you want to do.

HTH,
David :wink:
@dadoonet

Le 27 nov. 2011 à 02:24, Eugene Strokin eug...@strokin.info a écrit :

Hello,
In one index I have 3 different types of documents. One, has IDs of
other two.
For example:
Type 1:
{ "post":{
"properties":{
"postId":{"type":"string", index:"not_analyzed"},
"description":{"type":"string"},
"categoryId":{"type":"string", index:"not_analyzed"},
"userId":{"type":"string", index:"not_analyzed"},
} } }

Type 2:
{ "user":{
"properties":{
"userId":{"type":"string", index:"not_analyzed"},
"screenName":{"type":"string", index:"not_analyzed"},
} } }

Type 3:
{ "category":{
"properties":{
"categoryId":{"type":"string", index:"not_analyzed"},
"categoryName":{"type":"string", index:"not_analyzed"},
} } }

Currently I make 2 requests, one for the post, and the second one for
the user and category.
Could I get everything at once from a single request?

Thank you,
Eugene S.