假设我索引了一个看起来像这样的对象:
{
firstName: "Ben"
lastName: "McCann"
urls: [{ canonical: "http://www.benmccann.com" }]
emails: [{ canonical: "ben@ben.com" }]
}
然后如何创建对“Ben”或“McCann”或“ben@ben.com”的搜索?
SearchRequest request = new SearchRequest(INDEX)
.source(new SearchSourceBuilder().query(QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("firstName", "Ben"))
.should(QueryBuilders.matchQuery("lastName", "McCann"))
.should(QueryBuilders.nestedQuery("emails", QueryBuilders.matchQuery("emails.canonical", "ben@ben.com")))));