简体   繁体   中英

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

 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. we have requirement like facebook like user search order by friends, mutual friends (counts)

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.

Can you try checking for Neo4j which is graph database and would help you in traversing the relationships and search as well.

I don't know anything about Neo4j but I do think the above poster has a point. I'm not sure that this is the sort of thing for which Solr was designed. 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. 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". 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)". Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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