小编Ale*_*xis的帖子

具有嵌套字段和映射的Spring Data弹性搜索

我正在使用spring-data-elasticsearch和elasticsearch来查询文档.我想对嵌套文档进行嵌套查询.

我在java中有这个:

@Document(indexName = "as", type = "a", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
class A {

     @Id
     private String Id;

     @Field(type = String, index = analyzed, store = true)
     private String field1;

     // ... Many more Fields.

     @NestedField(type = FieldType.Object, index = analyzed, store = true, dotSuffix = "accounts")
     private List<B> bs;

     // ... getters and setters
}
Run Code Online (Sandbox Code Playgroud)

class B { // some normal pojo }
Run Code Online (Sandbox Code Playgroud)

当我让spring-data进行映射时,我得到:

"a": {
    "properties": {
        "bs": …
Run Code Online (Sandbox Code Playgroud)

elasticsearch spring-data spring-data-elasticsearch

11
推荐指数
1
解决办法
2万
查看次数