简体   繁体   English

SOLR架构设计和搜索

[英]SOLR schema design and searching

Hi i have like following table structure where i need to do simple users search, can any one give me suggestion how i have to design solr schema for this and query 嗨,我喜欢下面的表结构,我需要做简单的用户搜索,任何人都可以给我建议我如何为此设计solr架构和查询

 userid    -  name

  1       -   pot tot
  2       -   peter kate
  3       -   jack henry     
  4       -   jack cope

 id  -  userid   -  friendsid  (foreignkey table)

  1  -   1       -   jack henry 
  2  -   1       -   peter kate
  3  -   3       -   pot tot 
  4  -   2       -   pot tot

when user 1 - (pot tot) is searching for "jack" he has to see "jack henry" as 1 st result because he is mutual friends. 当用户1 - (pot tot)搜索“jack”时,他必须将“jack henry”视为第一个结果,因为他是共同的朋友。 we have requirement like facebook like user search order by friends, mutual friends (counts) 我们有像Facebook这样的要求,如朋友的用户搜索顺序,共同的朋友(计数)

You primary want to deal with relationship and search. 你主要想要处理关系和搜索。
Not sure if Solr would be able to get you the relationship parts out of the box. 不确定Solr是否能够为您提供开箱即用的关系部件。

Can you try checking for Neo4j which is graph database and would help you in traversing the relationships and search as well. 你可以尝试检查Neo4j这是图形数据库,并帮助你遍历关系和搜索。

I don't know anything about Neo4j but I do think the above poster has a point. 我对Neo4j一无所知,但我认为上面的海报有一点意义。 I'm not sure that this is the sort of thing for which Solr was designed. 我不确定这是Solr设计的那种东西。 Nevertheless, something you might try: 不过,您可以尝试一下:

<field name="user_id" type="slong" indexed="true" stored="true" required="true" />
<field name="user_name" type="text" indexed="true" stored="true" required="true" />
<field name="friend_id" type="slong" indexed="true" stored="true" required="false" multiValued="true" />

This allows each user to have 0 to many friends in the Solr index. 这允许每个用户在Solr索引中拥有0到多个朋友。 If you have a user named "Jack Henry" with a user_id of 3, then finding those who are friends of Jack Henry would be as simple as "?q=friend_id:3". 如果你有一个名为“Jack Henry”且user_id为3的用户,那么找到那些杰克亨利的朋友就像“?q = friend_id:3”一样简单。 If you have another user named "Peter Kate" with a user_id of 2, then finding mutual friends of Jack Henry and Peter Kate can be done as follows: "?q=friend_id:(2 AND 3)". 如果你有另一个名为“Peter Kate”且user_id为2的用户,则可以按如下方式找到Jack Henry和Peter Kate的共同朋友:“?q = friend_id:(2 AND 3)”。 Hope this helps. 希望这可以帮助。

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

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