简体   繁体   English

如何使用Elasticsearch在数组中搜索字段

[英]How to search a field in array using elasticsearch

I am using the index array field json as, 我正在使用索引数组字段json作为,

"productdetailsarray":
{
"properties":{
"producttone" : { "type" : "integer", "store" : "yes", "precision_step" : "8" },
"productsaleid" : { "type" : "integer", "store" : "yes", "precision_step" : "8" },
"productcoverage" : { "type" : "integer", "store" : "yes", "precision_step" : "8" },
"productdataid" : { "type" : "integer", "store" : "yes", "precision_step" : "8" },
"productid" : { "type" : "integer", "store" : "yes", "precision_step" : "8" }}
}

How to search the data inside the array? 如何在数组内部搜索数据?

Simple parse the JSon using a library like GSon: 使用GSon之类的库简单解析JSon:

MyClassToModelTheData data = new Gson().fromJson(theJsonString, MyClassToModelTheData.class);

Once in object-form, you can use any of the standard Java constructs to search the data. 一旦以对象形式出现,您就可以使用任何标准Java构造来搜索数据。

If you use Maven, you can use the following to import GSon: 如果使用Maven,则可以使用以下命令导入GSon:

<!-- For parsing JSon -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>1.7.1</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM