What does "adjust_pure_negative" flag do?

I am using Boolean query builder which when looking at the query being run has 'adjust_pure_negative' flag set to true when doing google searching the documentation for this flag doesn't come up. What exactly does 'adjust_pure_negative' signify?

Example using (ES 5.0 api):

    final BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
    boolQueryBuilder.must(QueryBuilders.termQuery("some-term", "some-val"));
    System.out.println(boolQueryBuilder.buildAsBytes().utf8ToString());

Output:

    {"bool":{"must":[{"term":{"some-term":{"value":"some-val","boost":1.0}}}],"disable_coord":false,"adjust_pure_negative":true,"boost":1.0}}

You can ignore it. It "does the right thing" when calling Lucene when all clauses are "must_not" clauses (no shoulds or musts). Ordinarily Lucene expects some positive clauses so would return nothing. Elasticsearch adjusts for this case by adding a must match_all type clause which means Lucene would then provide results, filtered by the must_nots.
True is the default setting and anything else seems non-sensical.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.