Class DefaultQueryBuilder

java.lang.Object
org.codelibs.fess.query.DefaultQueryBuilder
All Implemented Interfaces:
org.opensearch.core.common.io.stream.NamedWriteable, org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject, org.opensearch.index.query.QueryBuilder, org.opensearch.index.query.Rewriteable<org.opensearch.index.query.QueryBuilder>

public class DefaultQueryBuilder extends Object implements org.opensearch.index.query.QueryBuilder
Default implementation of QueryBuilder that wraps other QueryBuilder instances and provides additional functionality for adding inner queries dynamically. Supports both BoolQueryBuilder and DisMaxQueryBuilder as underlying implementations.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent

    org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable

    org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
  • Field Summary

    Fields inherited from interface org.opensearch.index.query.Rewriteable

    MAX_REWRITE_ROUNDS

    Fields inherited from interface org.opensearch.core.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultQueryBuilder(org.opensearch.index.query.QueryBuilder queryBuilder)
    Creates a new DefaultQueryBuilder wrapping the specified QueryBuilder.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(org.opensearch.index.query.QueryBuilder innerQueryBuilder)
    Adds an inner query builder to the wrapped query.
    float
    Returns the boost value.
    org.opensearch.index.query.QueryBuilder
    boost(float boost)
    Sets the boost value.
    boolean
     
    org.opensearch.index.query.QueryBuilder
    filter(org.opensearch.index.query.QueryBuilder filter)
    Applies a filter to the query.
    Returns the name of the query.
    Returns the writeable name of the wrapped query builder.
    int
     
    boolean
    Returns whether this query builder is a fragment.
    Returns the query name.
    org.opensearch.index.query.QueryBuilder
    queryName(String queryName)
    Sets the query name.
    org.opensearch.index.query.QueryBuilder
    rewrite(org.opensearch.index.query.QueryRewriteContext queryShardContext)
    Rewrites the query using the provided rewrite context.
    org.apache.lucene.search.Query
    toQuery(org.opensearch.index.query.QueryShardContext context)
    Creates a Lucene Query from this query builder.
     
    org.opensearch.core.xcontent.XContentBuilder
    toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params)
     
    void
    visit(org.opensearch.index.query.QueryBuilderVisitor visitor)
     
    void
    writeTo(org.opensearch.core.common.io.stream.StreamOutput out)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opensearch.index.query.QueryBuilder

    supportsIntraSegmentSearch
  • Constructor Details

    • DefaultQueryBuilder

      public DefaultQueryBuilder(org.opensearch.index.query.QueryBuilder queryBuilder)
      Creates a new DefaultQueryBuilder wrapping the specified QueryBuilder.
      Parameters:
      queryBuilder - the query builder to wrap (must be BoolQueryBuilder or DisMaxQueryBuilder)
      Throws:
      IllegalArgumentException - if the query builder type is not supported
  • Method Details

    • add

      public DefaultQueryBuilder add(org.opensearch.index.query.QueryBuilder innerQueryBuilder)
      Adds an inner query builder to the wrapped query. For BoolQueryBuilder, adds as a should clause. For DisMaxQueryBuilder, adds as a query.
      Parameters:
      innerQueryBuilder - the query builder to add
      Returns:
      this instance for method chaining
    • getWriteableName

      public String getWriteableName()
      Returns the writeable name of the wrapped query builder.
      Specified by:
      getWriteableName in interface org.opensearch.core.common.io.stream.NamedWriteable
      Returns:
      the writeable name
    • toQuery

      public org.apache.lucene.search.Query toQuery(org.opensearch.index.query.QueryShardContext context) throws IOException
      Creates a Lucene Query from this query builder.
      Specified by:
      toQuery in interface org.opensearch.index.query.QueryBuilder
      Parameters:
      context - the query shard context
      Returns:
      the Lucene Query
      Throws:
      IOException - if an I/O error occurs
    • isFragment

      public boolean isFragment()
      Returns whether this query builder is a fragment.
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContent
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContentObject
      Returns:
      true if this is a fragment, false otherwise
    • queryName

      public org.opensearch.index.query.QueryBuilder queryName(String queryName)
      Sets the query name.
      Specified by:
      queryName in interface org.opensearch.index.query.QueryBuilder
      Parameters:
      queryName - the query name to set
      Returns:
      the query builder
    • queryName

      public String queryName()
      Returns the query name.
      Specified by:
      queryName in interface org.opensearch.index.query.QueryBuilder
      Returns:
      the query name
    • boost

      public float boost()
      Returns the boost value.
      Specified by:
      boost in interface org.opensearch.index.query.QueryBuilder
      Returns:
      the boost value
    • boost

      public org.opensearch.index.query.QueryBuilder boost(float boost)
      Sets the boost value.
      Specified by:
      boost in interface org.opensearch.index.query.QueryBuilder
      Parameters:
      boost - the boost value to set
      Returns:
      the query builder
    • filter

      public org.opensearch.index.query.QueryBuilder filter(org.opensearch.index.query.QueryBuilder filter)
      Applies a filter to the query.
      Specified by:
      filter in interface org.opensearch.index.query.QueryBuilder
      Parameters:
      filter - the filter query builder
      Returns:
      the query builder
    • getName

      public String getName()
      Returns the name of the query.
      Specified by:
      getName in interface org.opensearch.index.query.QueryBuilder
      Returns:
      the query name
    • rewrite

      public org.opensearch.index.query.QueryBuilder rewrite(org.opensearch.index.query.QueryRewriteContext queryShardContext) throws IOException
      Rewrites the query using the provided rewrite context.
      Specified by:
      rewrite in interface org.opensearch.index.query.QueryBuilder
      Specified by:
      rewrite in interface org.opensearch.index.query.Rewriteable<org.opensearch.index.query.QueryBuilder>
      Parameters:
      queryShardContext - the query rewrite context
      Returns:
      the rewritten query builder
      Throws:
      IOException - if an I/O error occurs during rewriting
    • visit

      public void visit(org.opensearch.index.query.QueryBuilderVisitor visitor)
      Specified by:
      visit in interface org.opensearch.index.query.QueryBuilder
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • writeTo

      public void writeTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException
      Specified by:
      writeTo in interface org.opensearch.core.common.io.stream.Writeable
      Throws:
      IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object