匹配由Titan索引的弹性搜索数据 [英] Matching elasticsearch data indexed by Titan

查看:189
本文介绍了匹配由Titan索引的弹性搜索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在弹性搜索中索引了泰坦数据,它工作正常,并且索引,但是当我使用REST API查看弹性搜索中的数据时。列/属性名称看起来与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 

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


默认情况下,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


I have indexed titan data in elasticsearch, it worked fine and indexed but when i see the data in elasticsearch using REST API. the column/property name looks different than from Titan.

For example i have indexed age while inserting data to Titan

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

and if i see same in elasticsearch

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

Looking at the data i can understand "6bp" is age. how this conversion is done? How can i decode it.?

My goal is to insert data to Titan index on ElasticSearch. The user query should search on ElasticSearch using ElasticSearch client becuase we need more search functionality that ElasticSearch supports, if data is searched then get the related result using Titan query.

解决方案

The field names are Long encoded. You can reverse encode using this class

com.thinkaurelius.titan.util.encoding.LongEncoding

or, an even better option if you can use it, would be to simply specify the search field names explicitly using the field mapping:

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

这篇关于匹配由Titan索引的弹性搜索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆