Class SimpleQuery

java.lang.Object
org.springframework.data.solr.core.query.SimpleQuery
All Implemented Interfaces:
FilterQuery, Query, SolrDataQuery
Direct Known Subclasses:
SimpleFacetAndHighlightQuery, SimpleFacetQuery, SimpleHighlightQuery

public class SimpleQuery extends Object implements Query, FilterQuery
Full implementation of Query that allows multiple options like pagination, grouping,...
  • Constructor Details

    • SimpleQuery

      public SimpleQuery()
    • SimpleQuery

      public SimpleQuery(Criteria criteria)
      Parameters:
      criteria -
    • SimpleQuery

      public SimpleQuery(String queryString)
      Parameters:
      queryString -
      Since:
      1.1
    • SimpleQuery

      public SimpleQuery(Criteria criteria, @Nullable org.springframework.data.domain.Pageable pageable)
      Parameters:
      criteria -
      pageable -
    • SimpleQuery

      public SimpleQuery(String queryString, org.springframework.data.domain.Pageable pageable)
      Parameters:
      queryString -
      pageable -
      Since:
      1.1
  • Method Details

    • fromQuery

      @Nullable public static final Query fromQuery(Query source)
    • fromQuery

      @Nullable public static <T extends SimpleQuery> T fromQuery(@Nullable Query source, @Nullable T destination)
    • addProjectionOnField

      public final <T extends Query> T addProjectionOnField(Field field)
      Description copied from interface: Query
      add given Field to those included in result. Corresponds to the fl parameter in solr.
      Specified by:
      addProjectionOnField in interface Query
      Returns:
    • addProjectionOnField

      public final <T extends Query> T addProjectionOnField(String fieldname)
    • addProjectionOnFields

      public final <T extends Query> T addProjectionOnFields(Field... fields)
    • addProjectionOnFields

      public final <T extends Query> T addProjectionOnFields(String... fieldnames)
    • setPageRequest

      public final <T extends Query> T setPageRequest(org.springframework.data.domain.Pageable pageable)
      Description copied from interface: Query
      restrict result to entries on given page. Corresponds to the start and row parameter in solr
      Specified by:
      setPageRequest in interface Query
      Returns:
    • setOffset

      public <T extends Query> T setOffset(Long offset)
      Description copied from interface: Query
      Set the number of rows to skip.
      Specified by:
      setOffset in interface Query
      Returns:
    • setRows

      public <T extends Query> T setRows(Integer rows)
      Description copied from interface: Query
      Set the number of rows to fetch.
      Specified by:
      setRows in interface Query
      Returns:
    • addGroupByField

      @Deprecated public final <T extends Query> T addGroupByField(Field field)
      Deprecated.
      Description copied from interface: Query
      add the given field to those used for grouping result Corresponds to '' in solr
      Specified by:
      addGroupByField in interface Query
      Returns:
    • addGroupByField

      @Deprecated public final <T extends Query> T addGroupByField(String fieldname)
      Deprecated.
      in favor of GroupOptions
      add grouping on field name
      Parameters:
      fieldname - must not be null
      Returns:
      See Also:
    • addSort

      public final <T extends Query> T addSort(@Nullable org.springframework.data.domain.Sort sort)
      Description copied from interface: Query
      Add Sort to query
      Specified by:
      addSort in interface Query
      Returns:
    • getSort

      public org.springframework.data.domain.Sort getSort()
      Specified by:
      getSort in interface Query
      Returns:
      null if not set
    • getPageRequest

      public org.springframework.data.domain.Pageable getPageRequest()
      Description copied from interface: Query
      Get page settings if defined.
      Specified by:
      getPageRequest in interface Query
      Returns:
    • getOffset

      @Nullable public Long getOffset()
      Description copied from interface: Query
      Get number of rows to skip.
      Specified by:
      getOffset in interface Query
    • getRows

      @Nullable public Integer getRows()
      Description copied from interface: Query
      Get number of rows to fetch.
      Specified by:
      getRows in interface Query
      Returns:
    • getGroupByFields

      @Deprecated public List<Field> getGroupByFields()
      Deprecated.
      Description copied from interface: Query
      Get group by fields if defined
      Specified by:
      getGroupByFields in interface Query
      Returns:
    • getProjectionOnFields

      public List<Field> getProjectionOnFields()
      Description copied from interface: Query
      Get projection fields if defined
      Specified by:
      getProjectionOnFields in interface Query
      Returns:
    • addFilterQuery

      public <T extends Query> T addFilterQuery(FilterQuery filterQuery)
      Description copied from interface: Query
      add query to filter results Corresponds to fq in solr
      Specified by:
      addFilterQuery in interface Query
      Returns:
    • setTimeAllowed

      public <T extends Query> T setTimeAllowed(Integer timeAllowed)
      Description copied from interface: Query
      The time in milliseconds allowed for a search to finish. Values <= 0 mean no time restriction.
      Specified by:
      setTimeAllowed in interface Query
      Returns:
    • getTimeAllowed

      @Nullable public Integer getTimeAllowed()
      Description copied from interface: Query
      Return the time (in milliseconds) allowed for a search to finish
      Specified by:
      getTimeAllowed in interface Query
      Returns:
    • setGroupOptions

      public <T extends Query> T setGroupOptions(GroupOptions groupOptions)
      Description copied from interface: Query
      Sets GroupOptions for this Query.
      Specified by:
      setGroupOptions in interface Query
      Returns:
    • getGroupOptions

      @Nullable public GroupOptions getGroupOptions()
      Specified by:
      getGroupOptions in interface Query
      Returns:
      group options
    • getStatsOptions

      @Nullable public StatsOptions getStatsOptions()
      Specified by:
      getStatsOptions in interface Query
      Returns:
      StatsOptions or null if not set.
    • setStatsOptions

      public <T extends Query> T setStatsOptions(StatsOptions statsOptions)
      Description copied from interface: Query
      Set StatsOptions for this Query.
      Specified by:
      setStatsOptions in interface Query
      Returns:
    • getFilterQueries

      public List<FilterQuery> getFilterQueries()
      Description copied from interface: Query
      Get filter queries if defined
      Specified by:
      getFilterQueries in interface Query
      Returns:
    • getDefaultOperator

      public Query.Operator getDefaultOperator()
      Description copied from interface: Query
      Get the specified default operator for query expressions, overriding the default operator specified in the schema.xml file.
      Specified by:
      getDefaultOperator in interface Query
      Returns:
    • hasDefaultOperatorDefined

      public boolean hasDefaultOperatorDefined()
      Returns:
      true if current operator does not equal Query.Operator.NONE
    • setDefaultOperator

      public void setDefaultOperator(Query.Operator operator)
      Description copied from interface: Query
      Set the default operator q.op for query expressions
      Specified by:
      setDefaultOperator in interface Query
    • getDefType

      public String getDefType()
      Description copied from interface: Query
      Get the default type of query, if one has been specified. Overrides the default type specified in the solrconfig.xml file.
      Specified by:
      getDefType in interface Query
      Returns:
    • setDefType

      public void setDefType(String defType)
      Description copied from interface: Query
      Sets the default type to be used by the query.
      Specified by:
      setDefType in interface Query
    • setSpellcheckOptions

      public <T extends Query> T setSpellcheckOptions(SpellcheckOptions spellcheckOptions)
      Description copied from interface: Query
      Set the SpellcheckOptions to enable spellchecking.
      Specified by:
      setSpellcheckOptions in interface Query
      Parameters:
      spellcheckOptions - can be null.
      Returns:
      never null.
    • getSpellcheckOptions

      @Nullable public SpellcheckOptions getSpellcheckOptions()
      Specified by:
      getSpellcheckOptions in interface Query
      Returns:
      null if not set.
    • addCriteria

      public final <T extends SolrDataQuery> T addCriteria(Criteria criteria)
      Add an criteria to the query. The criteria will be connected using 'AND'.
      Parameters:
      criteria - must not be null.
      Returns:
    • getCriteria

      @Nullable public Criteria getCriteria()
      Returns:
      null if not set
    • setJoin

      public void setJoin(Join join)
      Set values for join !join from=inner_id to=outer_id
    • getJoin

      @Nullable public Join getJoin()
      Returns:
      null if not set
    • getRequestHandler

      @Nullable public String getRequestHandler()
    • setRequestHandler

      public void setRequestHandler(String requestHandler)