Search code examples
clojuregremlintinkerpopjanusgraph

Janusgraph - How to make case insensitive search with spaces - textContainsRegex not working with spaces


I'm new to the Janusgraph Database. I have a requirement where I need to search the jansugraph with a query parameter.

Example

I have name with a value, "Janus Graph Engine". To search this, I'm using below predicate with regex expression.

g.V().has("name", textContainsRegex(".*graph.*")

Since, the above predicate is case-insensitive, I could able to get result even if I use query like below also

g.V().has("name", textContainsRegex(".*Graph.*")

But the problem is, when I wanted to put the search string including spaces I'm not able to get result.

g.V().has("name", textContainsRegex(".*graph engine.*")

Is there any way where we can search for text/string that should be case-insensitive as well as able to accept the spaces in between?

Because my requirement is when user types like this "nus gr", it should able to get the result since "nus gr" is the continuation in the entire string.

I have one more predicate called "textRegex", this accepts spaces but its case-sensitive.

Can you help me with this regard?

Thanks a lot for your time.


Solution

  • This is a question from a while ago but I noticed it is not yet answered.

    You can tell the textRegex function to ignore case as follows:

    gremlin> g.addV('test').property('x','Janus Graph Engine')
    ==>v[4288]
    
    gremlin> g.V().has("x", textRegex(".*(?i)nUs[ ]g.*"))
    ==>v[4288]