Reputation: 3898
I'm totally bamboozled, since this code was working previously.
I'm trying to create a Mixed Edge index on an edge property in my graph (trxn_dt_int
).
It shows, from the output of mgmt.printSchema()
, that it was created successfully (see, Status: Enabled, I've highlighted the relevant rows).
mgmt.printSchema()
output:
==>------------------------------------------------------------------------------------------------
Vertex Label Name | Partitioned | Static |
---------------------------------------------------------------------------------------------------
entity | false | false |
---------------------------------------------------------------------------------------------------
Edge Label Name | Directed | Unidirected | Multiplicity |
---------------------------------------------------------------------------------------------------
transacts_with | true | false | MULTI |
---------------------------------------------------------------------------------------------------
Property Key Name | Cardinality | Data Type |
---------------------------------------------------------------------------------------------------
benef_nm | SINGLE | class java.lang.String |
orig_nm | SINGLE | class java.lang.String |
trxn_dt_int | SINGLE | class java.lang.Float |
---------------------------------------------------------------------------------------------------
Vertex Index Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
***************************************************************************************************
Edge Index (VCI) Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
byDate | Mixed | false | search | trxn_dt_int: ENABLED|
***************************************************************************************************
---------------------------------------------------------------------------------------------------
Relation Index | Type | Direction | Sort Key | Order | Status |
Here's my groovy script to create the index:
graph.tx().rollback()
mgmt = graph.openManagement()
mgmt.printSchema()
// get index count
index_count = mgmt.getGraphIndexes(Edge.class).size()
if (index_count==0) {
// create edge schema for graph (only for properties to be indexed)
if (!mgmt.getEdgeLabel('transacts_with') & !mgmt.getPropertyKey('trxn_dt_int')) {
transacts_with = mgmt.makeEdgeLabel('transacts_with').make()
trxn_dt = mgmt.makePropertyKey('trxn_dt_int').dataType(Float.class).make()
mgmt.addProperties(transacts_with, trxn_dt)
}
mgmt.commit()
mgmt = graph.openManagement()
if (!mgmt.containsGraphIndex("byDate")) {
trxn_dt = mgmt.getPropertyKey('trxn_dt_int')
mgmt.buildIndex('byDate', Edge.class).addKey(trxn_dt).buildMixedIndex('search')
mgmt.commit()
ManagementSystem.awaitGraphIndexStatus(graph, 'byDate').call()
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex("byDate"), SchemaAction.REINDEX).get()
mgmt.commit()
}
}
When I query the elasticsearch server, it shows it's there:
curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d\ -f3
> janusgraph_bydate
When I query for the number of documents, it returns 0.
curl --silent 'http://127.0.0.1:9200/janusgraph_bydate/_count?q=*'
> {"count":0,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}
My question is, why aren't any documents being added?
I initially thought I had to reindex, but when I tried, it still didn't work. No errors at all.
mgmt = graph.openManagement()
index = mgmt.getGraphIndex('byDate')
mgmt.updateIndex(index, SchemaAction.REINDEX).get()
mgmt.commit()
Setup:
Upvotes: 0
Views: 250
Reputation: 3898
Well, this is embarrassing; it wasn't updating the index with new data because my machine lacked sufficient memory, but also didn't offer warnings to suggest this. After freeing up memory elsewhere it now works again.
Upvotes: 1