Elasticsearch 2.2 Java API最小字段长度

时间:2016-08-02 13:15:38

标签: java elasticsearch

使用以下代码我想搜索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?

0 个答案:

没有答案