Spring弹性搜索获取嵌套对象值

时间:2020-04-29 00:50:38

标签: spring spring-boot elasticsearch

我正在使用带有弹性搜索的Spring。我有两个对象:

@Document(indexName = "user")
public class user {

    // unique id of client
    @Id
    private Long id;

    //The email of the user
    private String email;

    @Field(type = FieldType.Nested, includeInParent = true)
    private List<Company> companyList = new ArrayList<>();

}

public class Company {

    private Long companyId;

    //The name of the company
    private String name;

        private String city;
    }

在没有用户ID的情况下,如何通过ID获得公司的名称?
谢谢

0 个答案:

没有答案