Currently my schema looks like this:
type Document {
id: ID!
title: String!
content: String!
keywords: [String!]! @search
}
I want to do a super simple relavance sorting according to how many keywords an arbitrary document has that match the words in a search. To me the pseudo code sounds simple:
user will input a "searchTerm"
targetKeywords = searchTerm split by spaces
for each Document in the database:
matches = intersection between Document.keywords and targetKeywords
Document.count = the length of matches
done
relavantDocuments = sort Documents by count in decending order
return first 10 relavantDocuments
Postgresql and MongoDB both have aggregation pipelines that can do this whole query in on the database as opposed to a server downloading the entire content of the database to do the search. Does anyone know a DGraph oriented method of doing this kind of search? Any information on graphical sorting methods would also be helpful, there’s not much of a community around DGraph.