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.
  • Field Details

  • Constructor Details

    • QueryParserBase

      public QueryParserBase(@Nullable org.springframework.data.mapping.context.MappingContext<? extends SolrPersistentEntity<?>,SolrPersistentProperty> mappingContext)
      Parameters:
      mappingContext -
      Since:
      4.0
  • Method Details

    • getQueryString

      public String getQueryString(SolrDataQuery query, @Nullable Class<?> domainType)
      Description copied from interface: QueryParser
      Get the queryString to use withSolrQuery.setParam(CommonParams.Q, "queryString"}
      Specified by:
      getQueryString in interface QueryParser
      domainType - 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: QueryParser
      Register an additional converter for transforming object values to solr readable format
      Specified by:
      registerConverter in interface QueryParser
    • addPredicateProcessor

      public void addPredicateProcessor(QueryParserBase.PredicateProcessor processor)
      Parameters:
      processor -
    • createQueryStringFromNode

      @Deprecated public String createQueryStringFromNode(Node node)
      Deprecated.
      Create the plain query string representation of the given node.
      Parameters:
      node -
      Returns:
    • createQueryStringFromNode

      public String createQueryStringFromNode(Node node, @Nullable Class<?> domainType)
      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 public String createQueryStringFromNode(Node node, int position)
      Deprecated.
      Create the plain query string representation of the given node.
      Parameters:
      node -
      Returns:
    • createQueryStringFromNode

      public String createQueryStringFromNode(Node node, int position, @Nullable Class<?> domainType)
      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 protected String createQueryStringFromCriteria(Criteria criteria)
      Deprecated.
      Iterates criteria list and concats query string fragments to form a valid query string to be used with SolrQuery.setQuery(String)
      Parameters:
      criteria -
      Returns:
    • createQueryStringFromCriteria

      protected String createQueryStringFromCriteria(Criteria criteria, @Nullable Class<?> domainType)
      Iterates criteria list and concats query string fragments to form a valid query string to be used with SolrQuery.setQuery(String)
      Parameters:
      criteria -
      domainType -
      Returns:
      Since:
      4.0
    • createQueryFragmentForCriteria

      protected String createQueryFragmentForCriteria(Criteria part, @Nullable Class<?> domainType)
      Creates query string representation of a single critiera.
      Parameters:
      part -
      domainType -
      Returns:
    • getMappedFieldName

      protected String getMappedFieldName(Field field, @Nullable Class<?> domainType)
      Get the mapped field name using meta information derived from the given domain type.
      Parameters:
      field -
      domainType -
      Returns:
      Since:
      4.0
    • getMappedFieldName

      protected String getMappedFieldName(String fieldName, @Nullable Class<?> domainType)
      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)
      Create SolrClient readable String representation for CalculatedField.
      Parameters:
      calculatedField -
      Returns:
      Since:
      1.1
    • createFunctionFragment

      protected String createFunctionFragment(Function function, int level, @Nullable Class<?> domainType)
      Create SolrClient readable String representation for Function
      Parameters:
      function -
      Returns:
      Since:
      1.1
    • createFunctionFragment

      protected String createFunctionFragment(Function function, int level, @Nullable Class<?> domainType, Function.Context.Target target)
      Create SolrClient readable String representation for Function
      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 information start, rows to SolrQuery
      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 to SolrQuery
      Parameters:
      solrQuery -
      fields -
    • appendDefaultOperator

      protected void appendDefaultOperator(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable Query.Operator defaultOperator)
      Set q.op parameter for SolrQuery
      Parameters:
      solrQuery -
      defaultOperator -
    • appendTimeAllowed

      protected void appendTimeAllowed(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable Integer timeAllowed)
      Set SolrQuery.setTimeAllowed(Integer)
      Parameters:
      solrQuery -
      timeAllowed -
    • appendDefType

      protected void appendDefType(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable String defType)
      Set defType for SolrQuery
      Parameters:
      solrQuery -
      defType -
    • appendRequestHandler

      protected void appendRequestHandler(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable String requestHandler)
      Set request handler parameter for SolrQuery
      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 the Query does 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: QueryParser
      Convert given Query into a SolrQuery executable via SolrClient
      Specified by:
      constructSolrQuery in interface QueryParser
      domainType - used for mapping fields to properties. Can be null.
      Returns:
    • doConstructSolrQuery

      public abstract org.apache.solr.client.solrj.SolrQuery doConstructSolrQuery(QUERYTPYE query, @Nullable Class<?> domainType)
    • newFunctionContext

      protected Function.Context newFunctionContext(@Nullable Class<?> domainType, Function.Context.Target target)
      Create new new Function.Context for rendering functions.
      Parameters:
      domainType - can be null.
      target - context Function.Context.Target. Must not be null.
      Returns:
      new instance of Function.Context.
      Since:
      4.1