匹配 Titan 索引的 elasticsearch 数据

Matching elasticsearch data indexed by Titan

我已经在 elasticsearch 中为 titan 数据建立了索引,它工作正常并建立了索引,但是当我使用 REST API 在 elasticsearch 中看到数据时。 column/property 名称看起来与 Titan 不同。

例如,我在向 Titan 插入数据时索引了年龄

final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make();
mgmt.buildIndex("vertices",Vertex.class).addKey(age).buildMixedIndex(INDEX_NAME);

如果我在 elasticsearch 中看到相同的内容

{
      "_index" : "titan",
      "_type" : "vertices",
      "_id" : "sg",
      "_score" : 1.0,
      "_source":{"6bp":30}
    }, 

查看数据我可以理解“6bp”是年龄。这种转换是如何完成的?我怎样才能解码它?

我的目标是将数据插入 ElasticSearch 上的 Titan 索引。用户查询应该使用 ElasticSearch 客户端在 ElasticSearch 上搜索,因为我们需要 ElasticSearch 支持的更多搜索功能,如果搜索数据然后使用 Titan 查询获得相关结果。

字段名称是 Long 编码的。您可以使用此 class

进行反向编码
com.thinkaurelius.titan.util.encoding.LongEncoding

或者,如果可以的话,更好的选择是使用字段映射明确指定搜索字段名称:

By default, Titan will encode property keys to generate a unique field name for the property key in the mixed index. If one wants to query the mixed index directly in the external index backend can be difficult to deal with and are illegible. For this use case, the field name can be explicitly specified through a parameter.

mgmt = g.getManagementSystem()
name = mgmt.makePropertyKey('bookname').dataType(String.class).make()
mgmt.buildIndex('booksBySummary',Vertex.class).addKey(name,com.thinkaurelius.titan.core.schema.Parameter.of('mapped-name','bookname')).buildMixedIndex("search")
mgmt.commit()

http://s3.thinkaurelius.com/docs/titan/0.5.1/index-parameters.html#_field_mapping