Package org.codelibs.fess.entity
Class QueryContext
java.lang.Object
org.codelibs.fess.entity.QueryContext
Context object that holds query-related information and state during search processing.
Contains the query string, query builder, sort criteria, and various metadata.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringPrefix for queries that search only in title fields.protected static final StringPrefix for queries that search only in URL fields.protected StringThe default field to search in when no specific field is specified.protected booleanFlag indicating whether role-based query filtering should be disabled.Map storing field names and their associated query terms for logging.Set of query terms that should be highlighted in search results.protected org.opensearch.index.query.QueryBuilderThe OpenSearch query builder used for executing the search.protected StringThe original query string provided by the user.protected final List<org.opensearch.search.sort.SortBuilder<?>> List of sort builders to apply to the search query. -
Constructor Summary
ConstructorsConstructorDescriptionQueryContext(String queryString, boolean isQuery) Constructs a new QueryContext with the specified query string. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFieldLog(String field, String text) Adds a field and text pair to the field log for tracking query terms.voidaddFunctionScore(Consumer<List<org.opensearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder>> functionScoreQuery) Adds function score configuration to the query builder.voidaddHighlightedQuery(String text) Adds a query term to the highlighted query set.voidAdds additional query clauses using a boolean query builder.voidaddSorts(org.opensearch.search.sort.SortBuilder<?>... sortBuilders) Adds sort builders to the query context.Gets the default field for this query context.Gets the default field keywords from the field log.Gets the field log map containing field names and their associated query terms.Gets the set of highlighted query terms.org.opensearch.index.query.QueryBuilderGets the query builder for this context.Gets the processed query string.booleanhasSorts()Checks if any sort builders have been added to this context.booleanChecks if role-based query filtering is enabled.voidsetDefaultField(String defaultField) Sets the default field for this query context.voidsetQueryBuilder(org.opensearch.index.query.QueryBuilder queryBuilder) Sets the query builder for this context.voidDisables role-based query filtering for this context.List<org.opensearch.search.sort.SortBuilder<?>> Gets the list of sort builders for this query context.
-
Field Details
-
ALLINURL_FIELD_PREFIX
Prefix for queries that search only in URL fields.- See Also:
-
ALLINTITLE_FIELD_PREFIX
Prefix for queries that search only in title fields.- See Also:
-
queryBuilder
protected org.opensearch.index.query.QueryBuilder queryBuilderThe OpenSearch query builder used for executing the search. -
sortBuilderList
List of sort builders to apply to the search query. -
queryString
The original query string provided by the user. -
highlightedQuerySet
Set of query terms that should be highlighted in search results. -
fieldLogMap
Map storing field names and their associated query terms for logging. -
disableRoleQuery
protected boolean disableRoleQueryFlag indicating whether role-based query filtering should be disabled. -
defaultField
The default field to search in when no specific field is specified.
-
-
Constructor Details
-
QueryContext
Constructs a new QueryContext with the specified query string. Processes special query prefixes (allinurl:, allintitle:) and initializes request-scoped attributes for highlighting and field logging.- Parameters:
queryString- The query string to process.isQuery- Whether this is a search query (enables highlighting and logging).
-
-
Method Details
-
addFunctionScore
public void addFunctionScore(Consumer<List<org.opensearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder>> functionScoreQuery) Adds function score configuration to the query builder.- Parameters:
functionScoreQuery- Consumer that configures the function score filters.
-
addQuery
Adds additional query clauses using a boolean query builder.- Parameters:
boolQuery- Consumer that configures the boolean query.
-
setQueryBuilder
public void setQueryBuilder(org.opensearch.index.query.QueryBuilder queryBuilder) Sets the query builder for this context.- Parameters:
queryBuilder- The query builder to use.
-
addSorts
public void addSorts(org.opensearch.search.sort.SortBuilder<?>... sortBuilders) Adds sort builders to the query context.- Parameters:
sortBuilders- Variable number of sort builders to add.
-
hasSorts
public boolean hasSorts()Checks if any sort builders have been added to this context.- Returns:
- True if sort builders are present, false otherwise.
-
sortBuilders
Gets the list of sort builders for this query context.- Returns:
- The list of sort builders.
-
getQueryBuilder
public org.opensearch.index.query.QueryBuilder getQueryBuilder()Gets the query builder for this context.- Returns:
- The query builder.
-
addFieldLog
Adds a field and text pair to the field log for tracking query terms.- Parameters:
field- The field name.text- The query text for this field.
-
getDefaultKeyword
Gets the default field keywords from the field log.- Returns:
- List of keywords for the default field, or empty list if none.
-
addHighlightedQuery
Adds a query term to the highlighted query set.- Parameters:
text- The query text to highlight.
-
getQueryString
Gets the processed query string.- Returns:
- The query string.
-
roleQueryEnabled
public boolean roleQueryEnabled()Checks if role-based query filtering is enabled.- Returns:
- True if role query is enabled, false otherwise.
-
skipRoleQuery
public void skipRoleQuery()Disables role-based query filtering for this context. -
getDefaultField
Gets the default field for this query context.- Returns:
- The default field name, or null if not set.
-
setDefaultField
Sets the default field for this query context.- Parameters:
defaultField- The default field name to set.
-
getHighlightedQuerySet
Gets the set of highlighted query terms.- Returns:
- The set of highlighted query terms, or empty set if not initialized.
-
getFieldLogMap
Gets the field log map containing field names and their associated query terms.- Returns:
- The field log map, or empty map if not initialized.
-