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: b
Solr can do this with the GraphQuery operator.
https://issues.apache.org/jira/browse/SOLR-7543
It allows you to put documents in your index that contain a field for the "node_id" and a (multivalued) field for the "edge_id"
There are a few ways to structure this:
For case 1: Index a document for each user in the system with a field containing the "user_id" and another field containing "friend_ids".
At that point to do a search for all friends for user 555 would be:
{!graph from="user_id" to="friend_ids" maxDepth=1}user_id:555
To find friends of friends of the user
{!graph from="user_id" to="friend_ids" maxDepth=2}user_id:555
If you have other metadata fields on the user records such as a location field you could add that as a traversal filter to find my friends that live in Boston. This traversal filter is applied to each hop.
{!graph from="user_id" to="friend_ids" maxDepth=2 traversalFilter="location:Boston"}user_id:555
The above query would find the friends that live in Boston that are friends User 555's that live in Boston.