Jamie Lawson <jamier...@...>
I have a COMPOSITE index. It builds correctly, awaits completion as per JanusGraph Chapter 8 docs. All that is well. But I CANNOT USE THE INDEX.
When I call getIndexStatus() on the index it reports ENABLED. The graph tests topologically as expected (right vertices, right edges, right connectivity, no reason to believe there is a problem with the graph).
Here's a snippet of Scala code used to create the property key.
mgmt.makePropertyKey("Name").dataType(classOf[String]).cardinality(cardinality.SINGLE).make
This is about the most basic property key I can imagine. Then I build a COMPOSITE index called "myIndex" on that property key. I do all of the "await" stuff in Chapter 8. I get the following output as the index is built.
21:46:21,960 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:22,461 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:22,962 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:23,463 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:23,964 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:24,465 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:24,965 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:25,466 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:25,967 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:26,470 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:26,971 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:27,472 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:27,972 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:28,473 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:28,974 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:29,475 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:29,976 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:30,478 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:30,979 INFO GraphIndexStatusWatcher:81 - Some key(s) on index myIndex do not currently have status REGISTERED: date=INSTALLED 21:46:31,043 INFO ManagementLogger:152 - Received all acknowledgements for eviction [11] 21:46:31,043 INFO ManagementLogger:152 - Received all acknowledgements for eviction [12] 21:46:31,045 INFO ManagementSystem$UpdateStatusTrigger:848 - Set status REGISTERED on schema element myIndex with property keys [] 21:46:31,147 INFO ManagementLogger:152 - Received all acknowledgements for eviction [13] 21:46:31,481 INFO GraphIndexStatusWatcher:83 - All 1 key(s) on index myIndex have status REGISTERED 21:46:31,482 INFO IndexRepairJob:114 - Found index myIndex 21:46:31,484 INFO IndexRepairJob:114 - Found index myIndex 21:46:31,718 INFO ManagementSystem:1008 - Index update job successful for [myIndex]
This leads me to believe that the index is being prepared successfully. So then I build a graph. As mentioned above, the graph passes a multitude of topology tests.
The examples provided in Chapter 8 say that if I have an index built on a property key, and I want to search for vertices with a specific property value, JanusGraph will use the index to do so (no need to build a special INDEX QUERY thing, JanusGraph will recognize that it has an index and use it). So for instance, if I have a property key named "Name", and it is built as follows: and I want to see if I have any vertices where the "Name" property has value "Richard", I make the following call.
val result = { val vertexIter = graph.traversal.V().has("Name", "Richard") if (vertexIter.hasNext) Some(vertexIter.next) else None }
This is pretty much exactly the code in Chapter 8, or at least the second line is. And it woks. It finds the vertex and all is good. EXCEPT I get the warning:
22:09:34,568 WARN StandardJanusGraphTx:1273 - Query requires iterating over all vertices [(word = Person)]. For better performance, use indexes
This suggests that the query is NOT using the composite index created for that purpose, as Chapter 8 suggests!!! That's not good.
So fast forward to Chapter 22 and INDEX QUERY, noting that the examples in Chapter 22 all deal with MIXED INDICES and MIXED INDICES depend on the details of the backing store.
val mgmt = graph.openManagement
// Sanity check val myIndex = mgmt.getGraphIndex("myIndex") println(myIndex.getIndexStatus(graph.getPropertyKey("Name")) // prints out ENABLED
// Here, the long line of code in Chapter 22 broke. So I split it // into its separate pieces to see exactly where it was breaking. val queryString = "v.Name:(Richard)" val personQuery = graph.indexQuery("myIndex", queryString) // This works.
val queryResult = personQuery.vertices // BOOM! This is where it breaks!!! val queryVertices = queryResult.iterator // Never get here.
So it appears to create the index query just fine, but then when I ask for the vertices, it throws the following exception.
java.lang.IllegalArgumentException: [info] at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108) [info] at org.janusgraph.graphdb.database.IndexSerializer.getMixedIndex(IndexSerializer.java:693) [info] at org.janusgraph.graphdb.database.IndexSerializer.executeQuery(IndexSerializer.java:617) [info] at org.janusgraph.graphdb.query.graph.IndexQueryBuilder.execute(IndexQueryBuilder.java:193) [info] at org.janusgraph.graphdb.query.graph.IndexQueryBuilder.vertices(IndexQueryBuilder.java:212) [info] at <<my line here: val queryResult=personQuery.vertices
I am using the in-memory backing store. My JanusGraph configuration file is as follows:
The stack trace suggests that some (undocumented) precondition was not met. Can anyone help here to figure out how I can take advantage of the index once I've added it to the graph?
|