无法在Titan中添加混合索引

时间:2016-06-18 08:55:40

标签: elasticsearch cassandra titan

我想在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中搜索,即

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" : [ ]
  }
}

1 个答案:

答案 0 :(得分:2)

根据结果,似乎" 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()

有时,特别是在远程数据存储(通过高延迟网络)中,索引立即启用需要时间,等待索引启用可能有助于您的情况。