我在elasticsearch中为titan数据建立了索引,它可以正常工作并建立索引,但是当我使用REST API在elasticsearch中看到数据时。列/属性名称看起来与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查询获得相关结果。
最佳答案
字段名称是长编码的。您可以使用此类进行反向编码
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
关于solr - 匹配Titan索引的elasticsearch数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28697090/