如何在SpringDataElasticSearch中查询对象列表作为Map

5uzkadbs  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(0)|浏览(384)

我试图查询一个具有子字段的复杂对象,我不想设置所有字段,但我需要它们。
在我的存储库中,当我搜索传递 Map.class 工作正常,但是当我传递一个实体时 Map 房地产价格上涨 NullPointerException ```
elasticSearchOperations.get(id, Map.class, IndexCoordinates.of(index))

我的班级不工作,比如:

@Data
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class Todo {

@Field(name = "entries", type = FieldType.Object)
private List<Map> entries;

public Todo() {
    this.entries = Lists.newArrayList();
}

}

下面是示例Map,有很多字段不想Map到类上,这就是我使用的原因 `Map.class` 接口。

{
"todo":{
"mappings":{
"properties":{
"_created":{
"type":"date"
},
"_created_user":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"entries":{
"properties":{
"_created":{
"type":"date"
},
"_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"_updated":{
"type":"date"
},
"what":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
}
}
}

附:我不提供索引文档的服务,我的服务只是搜索文档。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题