Class BoolQuery.Builder

All Implemented Interfaces:
CopyableBuilder<BoolQuery.Builder,BoolQuery>, MutableBuilder<BoolQuery.Builder,BoolQuery>, ObjectBuilder<BoolQuery>
Enclosing class:
BoolQuery

public static class BoolQuery.Builder extends QueryBase.AbstractBuilder<BoolQuery.Builder> implements CopyableBuilder<BoolQuery.Builder,BoolQuery>
Builder for BoolQuery.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • copy

      @Nonnull public BoolQuery.Builder copy()
      Description copied from interface: CopyableBuilder
      Create a new builder CopyableBuilder that is a copy of this one.
      Specified by:
      copy in interface CopyableBuilder<BoolQuery.Builder,BoolQuery>
      Returns:
      a new builder instance.
    • self

      @Nonnull protected BoolQuery.Builder self()
      Specified by:
      self in class QueryBase.AbstractBuilder<BoolQuery.Builder>
    • adjustPureNegative

      @Nonnull public final BoolQuery.Builder adjustPureNegative(@Nullable Boolean value)
      Ensures correct behavior when a query contains only must_not clauses. By default set to true, OpenSearch adds a match-all clause to ensure results are returned from Lucene, with the must_not conditions applied as filters. If set to false, the query may return no results, as Lucene typically requires at least one positive condition.

      API name: adjust_pure_negative

    • filter

      @Nonnull public final BoolQuery.Builder filter(List<Query> list)
      The clause (query) must appear in matching documents. However, unlike must, the score of the query will be ignored.

      API name: filter

      Adds all elements of list to filter.

    • filter

      @Nonnull public final BoolQuery.Builder filter(Query value, Query... values)
      The clause (query) must appear in matching documents. However, unlike must, the score of the query will be ignored.

      API name: filter

      Adds one or more values to filter.

    • filter

      @Nonnull public final BoolQuery.Builder filter(Function<Query.Builder,ObjectBuilder<Query>> fn)
      The clause (query) must appear in matching documents. However, unlike must, the score of the query will be ignored.

      API name: filter

      Adds a value to filter using a builder lambda.

    • minimumShouldMatch

      @Nonnull public final BoolQuery.Builder minimumShouldMatch(@Nullable String value)
      API name: minimum_should_match
    • must

      @Nonnull public final BoolQuery.Builder must(List<Query> list)
      The clause (query) must appear in matching documents and will contribute to the score.

      API name: must

      Adds all elements of list to must.

    • must

      @Nonnull public final BoolQuery.Builder must(Query value, Query... values)
      The clause (query) must appear in matching documents and will contribute to the score.

      API name: must

      Adds one or more values to must.

    • must

      @Nonnull public final BoolQuery.Builder must(Function<Query.Builder,ObjectBuilder<Query>> fn)
      The clause (query) must appear in matching documents and will contribute to the score.

      API name: must

      Adds a value to must using a builder lambda.

    • mustNot

      @Nonnull public final BoolQuery.Builder mustNot(List<Query> list)
      The clause (query) must not appear in the matching documents. Because scoring is ignored, a score of 0 is returned for all documents.

      API name: must_not

      Adds all elements of list to mustNot.

    • mustNot

      @Nonnull public final BoolQuery.Builder mustNot(Query value, Query... values)
      The clause (query) must not appear in the matching documents. Because scoring is ignored, a score of 0 is returned for all documents.

      API name: must_not

      Adds one or more values to mustNot.

    • mustNot

      @Nonnull public final BoolQuery.Builder mustNot(Function<Query.Builder,ObjectBuilder<Query>> fn)
      The clause (query) must not appear in the matching documents. Because scoring is ignored, a score of 0 is returned for all documents.

      API name: must_not

      Adds a value to mustNot using a builder lambda.

    • should

      @Nonnull public final BoolQuery.Builder should(List<Query> list)
      The clause (query) should appear in the matching document.

      API name: should

      Adds all elements of list to should.

    • should

      @Nonnull public final BoolQuery.Builder should(Query value, Query... values)
      The clause (query) should appear in the matching document.

      API name: should

      Adds one or more values to should.

    • should

      @Nonnull public final BoolQuery.Builder should(Function<Query.Builder,ObjectBuilder<Query>> fn)
      The clause (query) should appear in the matching document.

      API name: should

      Adds a value to should using a builder lambda.

    • build

      @Nonnull public BoolQuery build()
      Builds a BoolQuery.
      Specified by:
      build in interface ObjectBuilder<BoolQuery>
      Throws:
      NullPointerException - if some of the required fields are null.