Lucene搜索结果按自定义顺序列表排序(每个用户都是唯一的) [英] Lucene search results sort by custom order list (unique to each user)

查看:129
本文介绍了Lucene搜索结果按自定义顺序列表排序(每个用户都是唯一的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的应用程序中验证了用户,他们可以访问最多500,000个项目的共享数据库。每个用户都有自己的面向公众的网站,并且需要能够优先显示他们自己网站上显示的项目(想想upvote)。

I have authenticated users in my application who have access to a shared database of up to 500,000 items. Each of the users has their own public facing web site and needs the ability to prioritize the items on display (think upvote) on their own site.

500,000个项目中它们最多只能有200个优先项目,其余项目的顺序不太重要。

out of the 500,000 items they may only have up to 200 prioritized items, the order of the rest of the items is of less importance.

每个用户都会以不同的方式对项目进行优先排序。

Each of the users will prioritize the items differently.

我最初在这里问了一个类似的mysql问题按列表排序的Mysql结果对每个用户都是唯一的并得到了一个很好的答案,但我相信更好的选择可能是选择非sql索引解决方案。

I initially asked a similar mysql question here Mysql results sorted by list which is unique for each user and got a good answer but i believe a better option may be to opt for a non sql indexed solution.

这可以在Lucene中完成吗?还有其他搜索技术会更好吗?

Can this be done in Lucene?, is there another search technology which would be better for this.

ps。 Google会根据您的搜索结果实施类似的类型设置,如果您已登录,则可以优先排序并排除自己的搜索结果。

ps. Google implements a similar type setup with their search results where you can prioritize and exclude your own search results if you are logged in.

更新:使用sphinx重新标记为i我一直在阅读文档,我相信它可以通过存储在内存中的每文档属性值来做我想要的事情 - 感兴趣的是从sphinx gurus听到任何反馈

Update: re-tagged with sphinx as i have been reading the documentation and i believe it may be able to do what i am looking for with "per-document attribute values" stored in memory - interested to hear any feedback on this from sphinx gurus

推荐答案

在构建索引时,您肯定希望在每个文档对象中存储item的id。有几种方法可以执行下一步,但是一个简单的方法是将优先级项目添加到您的搜索查询中,对于每个特殊项目都是这样的:

You'll definitely want to store the id of item in each document object when building your index. There's a few ways to do the next step, but an easy one would be take the prioritized items and add them to your search query, something like this for each special item:

"OR item_id=%d+X"

其中X是你想要使用的助推量。你可能需要凭经验调整这个数字,以确保只是upvoted不会把它放在列表的顶部,搜索完全不相关的东西。

where X is the amount of boost you'd like to use. You'll probably need to empirically tweak this number to make sure that just being "upvoted" doesn't put it to the top of a list searching for something totally unrelated.

这样做至少会阻止你进行许多烦人的后处理步骤,这些步骤需要你遍历整个结果集 - 希望在查询索引时可以正确排序。

Doing it this way will at least prevent you from a lot of annoying postprocessing steps that would require you to iterate over the whole result set -- hopefully the proper sorting will be there right from querying the index.

这篇关于Lucene搜索结果按自定义顺序列表排序(每个用户都是唯一的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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