We have a rather complex query that’s looking for a range of existing values in our graph. We have a predicate called Posting and Site. There are approximately 500K-1M nodes in the graph. Right now we’re indexing it as:
Posting: string @index(term) @count .
Site: string @index(term) .
Our query typically looks like:
{
Postings(func: has(Posting)) @filter(eq(Site, "test.com") AND (eq(Posting, "383939383") OR eq(Posting, "383939383") OR eq(Posting, "383939383") OR eq(Posting, "383939383"))) {
uid
}
}
Typically there will be about 100-150 ORs in this query. This looks obviously inefficient to us and are wondering what the best approach is for optimizing it.
Would this indexing strategy and query be the most performant:
{
Postings(func: anyofterms(Posting, "383939383 383939383 383939383 383939383 383939383 383939383 383939383 383939383"))) @filter(eq(Site, "test.com")) {
uid
}
}
Or would using a hash with the OR statements work best? Note that I’m moving the Site filter towards the filter to cull any irrelevant values I don’t want in case they duplicate amongst platforms.
Thanks,
David