Class QueryParserBase<QUERYTPYE extends SolrDataQuery>
java.lang.Object
org.springframework.data.solr.core.QueryParserBase<QUERYTPYE>
- All Implemented Interfaces:
QueryParser
- Direct Known Subclasses:
DefaultQueryParser,TermsQueryParser
public abstract class QueryParserBase<QUERYTPYE extends SolrDataQuery>
extends Object
implements QueryParser
Base Implementation of
QueryParser providing common functions for creating
SolrQuery.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceQueryParserBase.PredicateProcessorcreates a solr reable query string representation for a givenCriteria.Predicate -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQueryParserBase(org.springframework.data.mapping.context.MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd anotherQueryParserBase.PredicateProcessorprotected voidappendDefaultOperator(org.apache.solr.client.solrj.SolrQuery solrQuery, Query.Operator defaultOperator) Setq.opparameter forSolrQueryprotected voidappendDefType(org.apache.solr.client.solrj.SolrQuery solrQuery, String defType) SetdefTypeforSolrQueryprotected voidappendGeoParametersIfRequired(org.apache.solr.client.solrj.SolrQuery solrQuery, Query query, Class<?> domainType) Append a geo filter query if theQuerydoes not already define one but contains a distance projection.protected voidappendPagination(org.apache.solr.client.solrj.SolrQuery query, Long offset, Integer rows) Append pagination informationstart, rowstoSolrQueryprotected voidappendProjectionOnFields(org.apache.solr.client.solrj.SolrQuery solrQuery, List<Field> fields) Deprecated.protected voidappendProjectionOnFields(org.apache.solr.client.solrj.SolrQuery solrQuery, List<Field> fields, Class<?> domainType) Append field list toSolrQueryprotected voidappendRequestHandler(org.apache.solr.client.solrj.SolrQuery solrQuery, String requestHandler) Set request handler parameter forSolrQueryprotected voidappendTimeAllowed(org.apache.solr.client.solrj.SolrQuery solrQuery, Integer timeAllowed) SetSolrQuery.setTimeAllowed(Integer)org.apache.solr.client.solrj.SolrQueryconstructSolrQuery(SolrDataQuery query, Class<?> domainType) Convert given Query into a SolrQuery executable viaSolrClientprotected StringcreateCalculatedFieldFragment(CalculatedField calculatedField, Class<?> domainType) CreateSolrClientreadable String representation forCalculatedField.protected StringcreateFunctionFragment(Function function, int level, Class<?> domainType) CreateSolrClientreadable String representation forFunctionprotected StringcreateFunctionFragment(Function function, int level, Class<?> domainType, Function.Context.Target target) CreateSolrClientreadable String representation forFunctionprotected StringcreateQueryFragmentForCriteria(Criteria part, Class<?> domainType) Creates query string representation of a single critiera.protected StringcreateQueryStringFromCriteria(Criteria criteria) Deprecated.since 4.0.protected StringcreateQueryStringFromCriteria(Criteria criteria, Class<?> domainType) Iterates criteria list and concats query string fragments to form a valid query string to be used withSolrQuery.setQuery(String)Deprecated.since 4.0.createQueryStringFromNode(Node node, int position) Deprecated.since 4.0.createQueryStringFromNode(Node node, int position, Class<?> domainType) Create the plain query string representation of the given node using mapping information derived from the domain type.createQueryStringFromNode(Node node, Class<?> domainType) Create the plain query string representation of the given node using mapping information derived from the domain type.abstract org.apache.solr.client.solrj.SolrQuerydoConstructSolrQuery(QUERYTPYE query, Class<?> domainType) protected StringgetMappedFieldName(String fieldName, Class<?> domainType) Get the mapped field name using meta information derived from the given domain type.protected StringgetMappedFieldName(Field field, Class<?> domainType) Get the mapped field name using meta information derived from the given domain type.getQueryString(SolrDataQuery query, Class<?> domainType) Get the queryString to use withSolrQuery.setParam(CommonParams.Q, "queryString"}protected Function.ContextnewFunctionContext(Class<?> domainType, Function.Context.Target target) Create new newFunction.Contextfor renderingfunctions.protected StringprependJoin(String queryString, SolrDataQuery query, Class<?> domainType) Prepend!join from= to=to given queryStringvoidregisterConverter(org.springframework.core.convert.converter.Converter<?, ?> converter) Register an additional converter for transforming object values to solr readable formatMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.solr.core.QueryParser
constructSolrQuery, getQueryString
-
Field Details
-
CRITERIA_VALUE_SEPERATOR
- See Also:
-
DELIMINATOR
- See Also:
-
NOT
- See Also:
-
BOOST
- See Also:
-
conversionService
protected final org.springframework.core.convert.support.GenericConversionService conversionService
-
-
Constructor Details
-
QueryParserBase
public QueryParserBase(@Nullable org.springframework.data.mapping.context.MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) - Parameters:
mappingContext-- Since:
- 4.0
-
-
Method Details
-
getQueryString
Description copied from interface:QueryParserGet the queryString to use withSolrQuery.setParam(CommonParams.Q, "queryString"}- Specified by:
getQueryStringin interfaceQueryParserdomainType- used for mapping fields to properties. Can be null.- Returns:
- String representation of query without faceting, pagination, projection...
-
registerConverter
public void registerConverter(org.springframework.core.convert.converter.Converter<?, ?> converter) Description copied from interface:QueryParserRegister an additional converter for transforming object values to solr readable format- Specified by:
registerConverterin interfaceQueryParser
-
addPredicateProcessor
add anotherQueryParserBase.PredicateProcessor- Parameters:
processor-
-
createQueryStringFromNode
Deprecated.since 4.0. UsecreateQueryStringFromNode(Node, Class)insteadCreate the plain query string representation of the given node.- Parameters:
node-- Returns:
-
createQueryStringFromNode
Create the plain query string representation of the given node using mapping information derived from the domain type.- Parameters:
node-domainType- can be null.- Returns:
- Since:
- 4.0
-
createQueryStringFromNode
Deprecated.since 4.0. UsecreateQueryStringFromNode(Node, int, Class)instead.Create the plain query string representation of the given node.- Parameters:
node-- Returns:
-
createQueryStringFromNode
Create the plain query string representation of the given node using mapping information derived from the domain type.- Parameters:
node-position-domainType- can be null.- Returns:
- Since:
- 4.0
-
createQueryStringFromCriteria
Deprecated.since 4.0. UsecreateQueryStringFromCriteria(Criteria, Class)instead.Iterates criteria list and concats query string fragments to form a valid query string to be used withSolrQuery.setQuery(String)- Parameters:
criteria-- Returns:
-
createQueryStringFromCriteria
Iterates criteria list and concats query string fragments to form a valid query string to be used withSolrQuery.setQuery(String)- Parameters:
criteria-domainType-- Returns:
- Since:
- 4.0
-
createQueryFragmentForCriteria
Creates query string representation of a single critiera.- Parameters:
part-domainType-- Returns:
-
getMappedFieldName
Get the mapped field name using meta information derived from the given domain type.- Parameters:
field-domainType-- Returns:
- Since:
- 4.0
-
getMappedFieldName
Get the mapped field name using meta information derived from the given domain type.- Parameters:
fieldName-domainType-- Returns:
- Since:
- 4.0
-
createCalculatedFieldFragment
protected String createCalculatedFieldFragment(CalculatedField calculatedField, @Nullable Class<?> domainType) CreateSolrClientreadable String representation forCalculatedField.- Parameters:
calculatedField-- Returns:
- Since:
- 1.1
-
createFunctionFragment
protected String createFunctionFragment(Function function, int level, @Nullable Class<?> domainType) CreateSolrClientreadable String representation forFunction- Parameters:
function-- Returns:
- Since:
- 1.1
-
createFunctionFragment
protected String createFunctionFragment(Function function, int level, @Nullable Class<?> domainType, Function.Context.Target target) CreateSolrClientreadable String representation forFunction- Parameters:
function-- Returns:
- Since:
- 4.1
-
prependJoin
protected String prependJoin(String queryString, @Nullable SolrDataQuery query, @Nullable Class<?> domainType) Prepend!join from= to=to given queryString- Parameters:
queryString-query-domainType-- Returns:
-
appendPagination
protected void appendPagination(org.apache.solr.client.solrj.SolrQuery query, @Nullable Long offset, @Nullable Integer rows) Append pagination informationstart, rowstoSolrQuery- Parameters:
query-offset-rows-
-
appendProjectionOnFields
@Deprecated protected void appendProjectionOnFields(org.apache.solr.client.solrj.SolrQuery solrQuery, List<Field> fields) Deprecated. -
appendProjectionOnFields
protected void appendProjectionOnFields(org.apache.solr.client.solrj.SolrQuery solrQuery, List<Field> fields, @Nullable Class<?> domainType) Append field list toSolrQuery- Parameters:
solrQuery-fields-
-
appendDefaultOperator
protected void appendDefaultOperator(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable Query.Operator defaultOperator) Setq.opparameter forSolrQuery- Parameters:
solrQuery-defaultOperator-
-
appendTimeAllowed
protected void appendTimeAllowed(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable Integer timeAllowed) SetSolrQuery.setTimeAllowed(Integer)- Parameters:
solrQuery-timeAllowed-
-
appendDefType
protected void appendDefType(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable String defType) SetdefTypeforSolrQuery- Parameters:
solrQuery-defType-
-
appendRequestHandler
protected void appendRequestHandler(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable String requestHandler) Set request handler parameter forSolrQuery- Parameters:
solrQuery-requestHandler-
-
appendGeoParametersIfRequired
protected void appendGeoParametersIfRequired(org.apache.solr.client.solrj.SolrQuery solrQuery, Query query, @Nullable Class<?> domainType) Append a geo filter query if theQuerydoes not already define one but contains a distance projection.- Parameters:
query- must not be null.- Since:
- 4.1
-
constructSolrQuery
public org.apache.solr.client.solrj.SolrQuery constructSolrQuery(SolrDataQuery query, @Nullable Class<?> domainType) Description copied from interface:QueryParserConvert given Query into a SolrQuery executable viaSolrClient- Specified by:
constructSolrQueryin interfaceQueryParserdomainType- used for mapping fields to properties. Can be null.- Returns:
-
doConstructSolrQuery
-
newFunctionContext
protected Function.Context newFunctionContext(@Nullable Class<?> domainType, Function.Context.Target target) Create new newFunction.Contextfor renderingfunctions.- Parameters:
domainType- can be null.target- contextFunction.Context.Target. Must not be null.- Returns:
- new instance of
Function.Context. - Since:
- 4.1
-