【发布时间】:2020-10-09 03:58:05
【问题描述】:
我完全被迷住了,因为这段代码以前可以工作。
我正在尝试在我的图表 (trxn_dt_int) 中的边缘属性上创建混合边缘索引。
从mgmt.printSchema() 的输出中显示,它已成功创建(请参阅状态:已启用,我已突出显示相关行)。
mgmt.printSchema() 输出:
==>------------------------------------------------------------------------------------------------
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 |
这是我创建索引的 groovy 脚本:
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()
}
}
当我查询弹性搜索服务器时,它显示它在那里:
curl --silent 'http://127.0.0.1:9200/_cat/indices' | cut -d\ -f3
> janusgraph_bydate
当我查询文档数时,它返回 0。
curl --silent 'http://127.0.0.1:9200/janusgraph_bydate/_count?q=*'
> {"count":0,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0}}
我的问题是,为什么没有添加任何文档?
我最初认为我必须重新索引,但当我尝试时,它仍然没有用。完全没有错误。
mgmt = graph.openManagement()
index = mgmt.getGraphIndex('byDate')
mgmt.updateIndex(index, SchemaAction.REINDEX).get()
mgmt.commit()
设置:
- Janusgraph 0.5.1
- 弹性搜索 6.0.1
【问题讨论】:
-
“此代码以前可以工作” - 发生了什么变化?你能把问题一分为二吗?
标签: elasticsearch indexing groovy janusgraph reindex