如何使用ElasticSearch来实现社会搜索? [英] How can ElasticSearch be used to implement social search?

查看:131
本文介绍了如何使用ElasticSearch来实现社会搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ElasticSearch创建具有社交功能的商业搜索。我有一个商业目录,用户可以通过不同的方式与这些企业进行互动:通过审查他们,检查他们等。

I’m trying to create a business search with social features using ElasticSearch. I have a business directory, and users can interact with those businesses in different ways: by reviewing them, checking into them, etc.

当用户搜索业务时,我希望能够向他们展示他们的朋友在结果顶部进行互动的业务(或基于这些交互过滤)。

When a user searches for a business, I'd like to be able to show them the businesses that their friends have interacted with at the top of the results (or filter based on those interactions). What's the best way to set up my index to achieve this?

我可以想到有几个可能的解决方案,但我是初学者ES和我不知道会出现什么问题:

I can think have a few possible solutions, but I'm a beginner with ES and I'm not sure what will cause problems:


  1. 我可以使用多重功能,并创建一个单独的索引每个用户我已经排除了这一点,因为用户数量远远大于企业数量或用户特定内容的数量。

  1. I could use multi-tennancy and create a separate index for each user. I've ruled this out because the number of users is much greater than the amount of businesses or the amount of user-specific content.

我可以添加一个每个索引业务的用户/分数对列表。与业务互动的每个用户都将在那里,分数将代表他们与业务的互动量(这对我的过滤/排序目的来说足够好)。每当他们与业务互动时,我都会更新索引中的得分。这个问题是我只关心我的朋友的活动,所以我需要找出一些方法来考虑到我的朋友在创建商业综合成绩时是谁。我不知道如何在ES中这样做。

I could add a list of user/score pairs to each indexed business. Every user who has interacted with the business would be in there, and the score would represent the amount of interaction they'd had with the business (this is good enough for my filtering/sorting purposes). Every time they interact with the business, I would update the score in the index. The problem with this is that I only care about my friends' activity, so I would need to figure out some way to take into account who my friends are when creating a composite score for the business. I don't know how to do this in ES.

我可以创建一个类似的方案,而不是保持与业务交互的分数,评分将反映我朋友与业务的互动。这消除了对ElasticSearch中的社交图形进行建模的需要,但这意味着任何人在与企业进行互动时,都需要更新所有的朋友的分数。这也意味着每个业务的用户/分数对的列表将会更大,因为它需要包括任何有朋友与业务交互的人。

I could create a similar scheme, but instead of keeping score of my interactions with a business, the score would reflect my friends' interactions with the business. This takes away the need to model my social graph in ElasticSearch, but it does mean that any time a person interacts with a business, I would need to update all of their friends' scores. It would also mean that the list of user/score pairs for each business would be larger, since it'll need to include anybody who has a friend who has interacted with the business.

我可以想到的最终解决方案是跟踪企业发生的每个人的互动情况,并将其添加到ES中的业务文档中。这对我来说似乎不现实 - 它结合了其他解决方案的问题。但是这可能是保持索引更新的最简单的方法。

The final solution I can think of is to keep track of every individual interaction that happens to a business, and add it to business’s document in ES. This doesn’t seem realistic to me – it combines the problems from the other solutions. But it’s probably the most straightforward approach in terms of keeping the index up to date.

感谢您的帮助! / p>

Thanks for your help!

推荐答案

我投了一个修改的#2。

I'm voting for a modified #2.

将每个用户/分数对存储在业务单据本身内部,我将创建一个父/子关系。这可以让您更新小孩的分数(用户分数),而无需重新索引整个业务单据(以及所有其他用户分数)。

Instead of storing each user/score pair inside of the business document itself, I would create a Parent/Child relationship. This lets you update the score of the child (the user scores) without having to reindex the entire business document (and all the other user scores).

查看此页面对于一个伟大的教程父母/孩子大约在中途: http://www.spacevatican.org/2012/6/3/fun-with-elasticsearch-s-children-and-nested-documents/

Check out this page for a great tutorial parent/children are about halfway down: http://www.spacevatican.org/2012/6/3/fun-with-elasticsearch-s-children-and-nested-documents/

然后,您可以使用 has_child过滤器top_children查询仅查找您朋友得分的商家。有一些关于订购儿童文档的注意事项,但是该教程涵盖了这个教程,所以请确保你读到底部。

Then you can use a has_child filter or top_children query to find only those businesses that your friends have scores for. There are a few caveats about ordering children documents, but it's covered by that tutorial so make sure you read to the bottom.

然后我只是执行一个普通的查询所有非社会排名的搜索。

Then I'd just perform a normal query for all "non-social" ranked searches.

或者,您可以将所有内容整合在一起,并为您的朋友获得的比赛添加提升,以便每个角色都适当排列。执行两个查询可能会更容易,并自行组合。

Alternatively, you could lump everything together and add boosts to the matches that your friends have scored, so that everything ranks appropriately. It may just be easier to perform two queries and combine them yourself.

这篇关于如何使用ElasticSearch来实现社会搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆