Package org.codelibs.fess.query
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>
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.ParamsNested 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_ROUNDSFields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionDefaultQueryBuilder(org.opensearch.index.query.QueryBuilder queryBuilder) Creates a new DefaultQueryBuilder wrapping the specified QueryBuilder. -
Method Summary
Modifier and TypeMethodDescriptionadd(org.opensearch.index.query.QueryBuilder innerQueryBuilder) Adds an inner query builder to the wrapped query.floatboost()Returns the boost value.org.opensearch.index.query.QueryBuilderboost(float boost) Sets the boost value.booleanorg.opensearch.index.query.QueryBuilderfilter(org.opensearch.index.query.QueryBuilder filter) Applies a filter to the query.getName()Returns the name of the query.Returns the writeable name of the wrapped query builder.inthashCode()booleanReturns whether this query builder is a fragment.Returns the query name.org.opensearch.index.query.QueryBuilderSets the query name.org.opensearch.index.query.QueryBuilderrewrite(org.opensearch.index.query.QueryRewriteContext queryShardContext) Rewrites the query using the provided rewrite context.org.apache.lucene.search.QuerytoQuery(org.opensearch.index.query.QueryShardContext context) Creates a Lucene Query from this query builder.toString()org.opensearch.core.xcontent.XContentBuildertoXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) voidvisit(org.opensearch.index.query.QueryBuilderVisitor visitor) voidwriteTo(org.opensearch.core.common.io.stream.StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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
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
Returns the writeable name of the wrapped query builder.- Specified by:
getWriteableNamein interfaceorg.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:
toQueryin interfaceorg.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:
isFragmentin interfaceorg.opensearch.core.xcontent.ToXContent- Specified by:
isFragmentin interfaceorg.opensearch.core.xcontent.ToXContentObject- Returns:
- true if this is a fragment, false otherwise
-
queryName
Sets the query name.- Specified by:
queryNamein interfaceorg.opensearch.index.query.QueryBuilder- Parameters:
queryName- the query name to set- Returns:
- the query builder
-
queryName
Returns the query name.- Specified by:
queryNamein interfaceorg.opensearch.index.query.QueryBuilder- Returns:
- the query name
-
boost
public float boost()Returns the boost value.- Specified by:
boostin interfaceorg.opensearch.index.query.QueryBuilder- Returns:
- the boost value
-
boost
public org.opensearch.index.query.QueryBuilder boost(float boost) Sets the boost value.- Specified by:
boostin interfaceorg.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:
filterin interfaceorg.opensearch.index.query.QueryBuilder- Parameters:
filter- the filter query builder- Returns:
- the query builder
-
getName
Returns the name of the query.- Specified by:
getNamein interfaceorg.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:
rewritein interfaceorg.opensearch.index.query.QueryBuilder- Specified by:
rewritein interfaceorg.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:
visitin interfaceorg.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:
toXContentin interfaceorg.opensearch.core.xcontent.ToXContent- Throws:
IOException
-
writeTo
- Specified by:
writeToin interfaceorg.opensearch.core.common.io.stream.Writeable- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
toString
-