I want to know how to achieve this scenario as efficient as possible.
In a following situation,
There are many documents.
Users can choose documents to have. (just like facebook's like feature)
I'd like to search only from documents that a certain user has chosen. Because this is N:M mapping, I stored document index and (document id - user id) in a separate index.
What is the best possible way to achieve this? I've been spending a lot of time thinking for a good solution, but didn't come up with a good one. Can anyone enlighten me?
Since there is no join functionality in elasticsearch, then storing this relationship in a different index will not help. You can either reindex the doc with an array of not_analyzed field that has the user ids on a document that represents users that liked it. This will require you to reindex the whole doc again.
Another option is to have a child document associated with the main doc that represents a like, and then use a has_child filter to filter those out. This means that a like is just an index of a new doc that is a child doc to the "main" doc. Has child is a bit expensive, but will do the work.
I plan to try and tackle this "changing fields" problem in later versions. Its a big one to tackle though...
On Thursday, March 10, 2011 at 11:30 AM, Jeff Oh wrote:
I want to know how to achieve this scenario as efficient as possible.
In a following situation,
There are many documents.
Users can choose documents to have. (just like facebook's like feature)
I'd like to search only from documents that a certain user has chosen.
Because this is N:M mapping, I stored document index and (document id - user
id) in a separate index.
What is the best possible way to achieve this? I've been spending a lot of
time thinking for a good solution, but didn't come up with a good one. Can
anyone enlighten me?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.