Reputation: 2418
I'm trying to model user suggestion system in elasticsearch which takes into account users likes and profile.
I have the user structure like this:
user: {
id: 232344,
location: 'New York',
likes: [4545, 3434, 343]
}
I want to suggest users based on below three concepts:
1) users who liked me.
2) users like the one i liked. (similar location, etc)
3) mutual likes. (user a like user x. user b likes user x. suggest user a to b and vice versa.)
I have read about More like this
query in elasticsearch but i'm not sure if it can take into account all these scenarios.
How can i model these things in elasticsearch queries or should i consider using a graph database like neo4j?
Upvotes: 0
Views: 611
Reputation: 10288
1) Users who like me. Suppose that my id is 1
{
"query": {
"term" : { "likes" : 1 }
}
}
2) Check more like this api. Given a document id and a set of fields it responds with similar documents to the given one. There are lots of options so I recommend to read the documentation and see if it fits your use case.
3) mutual likes: Suppose I'm a
and I liked these users [1, 3, 5]
. This query will return b
if b
also liked one of those ids.
{
"query": {
"term" : { "likes" : [1, 3, 5] }
}
}
Upvotes: 1