2015-02-24 73 views
0

我已经在elasticsearch中建立了索引的titan数据,它工作良好并且索引良好,但是当我在使用REST API的elasticsearch中查看数据时。列/属性名称看起来不同于泰坦。匹配由Titan索引的elasticsearch数据

,比如我有索引的年龄,同时将数据插入到泰坦

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查询获取相关结果。

回答

2

字段名称是长编码的。你可以使用这个类

com.thinkaurelius.titan.util.encoding.LongEncoding 

,或者反向编码一个更好的选择,如果你可以使用它,是简单地明确地使用字段映射指定搜索字段名称:

默认情况下, Titan将对属性键进行编码,以便为混合索引中的属性键生成唯一的字段名称。如果想在外部索引后端直接查询混合索引,可能难以处理且难以辨认。对于这个用例,可以通过参数明确指定字段名称。

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