Search code examples
elasticsearchgremlinjanusgraph

JanusGraph with Elasticsearch index is not working


I have added mixed index in JanusGraph to support full-text search with Elasticsearch.

I have mixed index like:

myindex = mgmt.buildIndex("myesindex", Vertex.class)
    .addKey("name", Mapping.TEXTSTRING.asParameter())
    .addKey("sabindex", Mapping.TEXTSTRING.asParameter())
    .buildMixedIndex("search");

I am able to load data into Elasticsearch engine. Also I am able to execute the query successfully.

The issue I am facing is when I hit query :

g.V().has('code','abc').valueMap()
==>{str=[some text], code=[abc], sab=[sab], sabindex=[sabindex], name=[[some tex]]}

I am getting the result successfully, but when I try to search with name and code:

g.V().has('name', textContains('some text')).has('code','abc').valueMap()

code field is also indexed(composite)

At that time I am getting no result. Though data is present in graph and Elasticsearch.

And another scenario is same query with different name and code works successfully. I also rebuild the graph multiple times but not getting positive results.


Solution

  • The first query shows the value is name=[[some tex]]. It is missing the final t in text, so that explains why the query isn't matching on some text.

    If you instead do textContains('some tex'), you would get the same result as the first query. Using the profile() step would show that the myindex was utilized.

    See this gist of the recreate scenario.