cayleygraph / cayley

An open-source graph database
https://cayley.io
Apache License 2.0
14.86k stars 1.25k forks source link

A way to perform substring matching #917

Open trivigy opened 4 years ago

trivigy commented 4 years ago

This is more of a question. Is there a way to perform a query matching a substring of a subject or an object using the golang API? I cannot figure out how to do this and was wondering if it is even possible.

example Say I have a quad like this: <folder:abc> <path> "/some/path/to/nowhere" and I want to find all the nodes that have an object matching /some/path/*

trivigy commented 4 years ago

One solution I encountered is using a regex matching. But I am guessing this is highly inefficient. Any other recommendations are very welcome.

predPath, err := cayley.StartPath(r.DB).OutPredicates().
    RegexWithRefs(regexp.MustCompile("rdf:_\\d+")).
    Iterate(ctx).AllValues(r.DB)