简体   繁体   English

Solr Lucene-不知道如何为数据建立索引,以便对文档正确打分

[英]Solr Lucene - Not sure how to index data so documents scored properly

Here's my goal. 这是我的目标。 A user has a list of skill+proficiency tuples. 用户具有技能+熟练程度元组的列表。

We want to find users based on some skill/experience criteria: 我们想根据一些技能/经验标准找到用户:

  • java, novice Java,新手
  • php, expert PHP,专家

    mysql, advanced mysql,高级

Where the * skills are highly desired and all others are good to have. 高度需要*技能,而其他所有技能都很好的地方。 Users which meet or exceed (based on experience) would be ranked highest. 达到或超过(根据经验)的用户将排名最高。 But it should also degrade nicely. 但是它也应该很好地降级。 If no users have both java and php experience, but they have one of the highly desired skills they should be ranked at the top. 如果没有用户同时具有java和php的经验,但是他们具有高度期望的技能之一,那么他们应该排名第一。 Users with only one of the optional skills may appear at the bottom. 仅具有可选技能之一的用户可能会显示在底部。

An idea I had is to index a user's skills in fields like this: 我的想法是在这样的领域中索引用户的技能:

skill_novice: java
skill_novice: php
skill_advanced: php
skill_expert: php
skill_novice: mysql
skill_advanced: mysql

...so that at minimal I can do a logical query to find people who meeting the highly desired skills: ...这样我至少可以做一个逻辑查询来找到符合高度期望技能的人:

(skill_novice:java AND skill_expert:php)

but this doesn't degrade nicely (if no matches found) nor does it find the optional skills. 但这并不能很好地降级(如果找不到匹配项),也找不到可选技能。 Perhaps instead I can do something like this: 也许我可以做这样的事情:

skill_novice:java AND
  (skill_novice:php^0.1 OR skill_advanced:php^0.2 OR skill_expert:php^0.3)

Is there a better way to accomplish this? 有没有更好的方法可以做到这一点?

I think you could boost the field with the different values at index time: 我认为您可以在索引时间使用不同的值来增强字段:

  // mysql expert
  Field mysqlf = new Field("skill", "mysql", 
                                    Field.Store.YES, 
                                    Field.Index.ANALYZED); 
  mysqlf.setBoost(10.0F); 
  // mysql begginer
  mysqlf = new Field("skill", "mysql", 
                                    Field.Store.YES, 
                                    Field.Index.ANALYZED); 
  mysqlf.setBoost(1.0F); 

You need to enable norms for this to work. 您需要为此启用规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM