我想在 titan 中创建混合索引,所以我使用了这些 gremlin 命令
graph.tx().rollback()
mgmt.buildIndex('deviceIndex',Vertex.class).addKey(serialNumber,Mapping.STRING.asParameter()).addKey(manufacturer,Mapping.STRING.asParameter()).addKey(clas,Mapping.STRING.asParameter()).addKey(description,Mapping.TEXT.asParameter()).addKey(fw_version,Mapping.STRING.asParameter()).addKey(hw_version,Mapping.STRING.asParameter()).addKey(latitude).addKey(longitude).addKey(accuracy).addKey(measure_datetime).buildMixedIndex("search")
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, 'deviceIndex').call()
我得到的输出是:
GraphIndexStatusReport[success=false, indexName='deviceIndex', targetStatus=REGISTERED, notConverged={device_longitude=ENABLED, device_latitude=ENABLED, device_description=ENABLED, device_class=ENABLED, device_serial_number=ENABLED, device_fw_version=ENABLED, device_accuracy=ENABLED, device_hw_version=ENABLED, device_manufacturer=ENABLED, measure_datetime=ENABLED}, converged={}, elapsed=PT1M0.234S]
你能告诉我为什么输出中有一个success=false
吗?为什么查询失败?
=>编辑
我使用了g.V().has('device_latitude', (float)343.2435).toList()
,它没有给我任何关于整个图表正在被遍历的警告。但我无法从elasticsearch ie 进行搜索
GET http://localhost:9200/_search?pretty
结果
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
最佳答案
从结果来看,“deviceIndex”似乎已注册但尚未启用。您可以尝试看看下面的代码能否解决您的问题?
graph.tx().rollback()
mgmt.buildIndex('deviceIndex',Vertex.class).addKey(serialNumber,Mapping.STRING.asParameter()).addKey(manufacturer,Mapping.STRING.asParameter()).addKey(clas,Mapping.STRING.asParameter()).addKey(description,Mapping.TEXT.asParameter()).addKey(fw_version,Mapping.STRING.asParameter()).addKey(hw_version,Mapping.STRING.asParameter()).addKey(latitude).addKey(longitude).addKey(accuracy).addKey(measure_datetime).buildMixedIndex("search")
mgmt.commit()
graph.tx().commit()
ManagementSystem.awaitGraphIndexStatus(graph, 'deviceIndex').status(SchemaStatus.ENABLED).call()
有时,特别是在远程数据存储中(通过高延迟网络),索引需要一些时间才能立即启用,等待索引启用可能会对您的情况有所帮助。
关于elasticsearch - 无法在 Titan 中添加混合索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37895135/