使用以下代码我想搜索first_name和last_name:
TransportClient client = elasticSearchProvider.getClient();
SearchRequestBuilder requestBuilder = client.prepareSearch("migranthire").setTypes("refugee").setSearchType(SearchType.QUERY_THEN_FETCH);
//Queries
BoolQueryBuilder queryBuilder = new BoolQueryBuilder();
queryBuilder.must(QueryBuilders.queryStringQuery(query + "*"));
queryBuilder.should(QueryBuilders.multiMatchQuery(query + "", "first_name", "last_name").boost(2).operator(MatchQueryBuilder.Operator.AND));
if (talent != null && talent == 0) {
queryBuilder.must(QueryBuilders.queryStringQuery(0 + "").field("talent"));
}
//Active ones
queryBuilder.must(QueryBuilders.queryStringQuery(1 + "").field("active"));
requestBuilder.setQuery(queryBuilder);
requestBuilder.setFrom(start);
requestBuilder.setSize(limit);
requestBuilder.setFetchSource(new String[]{"id"}, null);
我唯一不知道的是 - >如何过滤掉搜索结果,其中first_name和last_name为空或者该字段的长度为< 1?