Spring Data Solr

org.springframework.data.solr.core.query
Class SimpleQuery

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

public class SimpleQuery
extends Object
implements Query, FilterQuery

Full implementation of Query that allows multiple options like pagination, grouping,...

Author:
Christoph Strobl, Rosty Kerei, Luke Corpe, Andrey Paramonov

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.data.solr.core.query.Query
Query.Operator
 
Field Summary
static Pageable DEFAULT_PAGE
           
 
Fields inherited from interface org.springframework.data.solr.core.query.Query
DEFAULT_PAGE_SIZE
 
Constructor Summary
SimpleQuery()
           
SimpleQuery(Criteria criteria)
           
SimpleQuery(Criteria criteria, Pageable pageable)
           
SimpleQuery(String queryString)
           
SimpleQuery(String queryString, Pageable pageable)
           
 
Method Summary
<T extends SolrDataQuery>
T
addCriteria(Criteria criteria)
          Add an criteria to the query.
<T extends Query>
T
addFilterQuery(FilterQuery filterQuery)
          add query to filter results Corresponds to fq in solr
<T extends Query>
T
addGroupByField(Field field)
          add the given field to those used for grouping result Corresponds to '' in solr
<T extends Query>
T
addGroupByField(String fieldname)
          add grouping on fieldname
<T extends Query>
T
addProjectionOnField(Field field)
          add given Field to those included in result.
<T extends Query>
T
addProjectionOnField(String fieldname)
           
<T extends Query>
T
addProjectionOnFields(Field... fields)
           
<T extends Query>
T
addProjectionOnFields(String... fieldnames)
           
<T extends Query>
T
addSort(Sort sort)
          Add Sort to query
static Query fromQuery(Query source)
           
static
<T extends SimpleQuery>
T
fromQuery(Query source, T destination)
           
 Criteria getCriteria()
           
 Query.Operator getDefaultOperator()
          Get the specified default operator for query expressions, overriding the default operator specified in the schema.xml file.
 String getDefType()
          Get the default type of query, if one has been specified.
 List<FilterQuery> getFilterQueries()
          Get filter queries if defined
 List<Field> getGroupByFields()
          Get group by fields if defined
 Join getJoin()
           
 Pageable getPageRequest()
          Get page settings if defined
 List<Field> getProjectionOnFields()
          Get projection fields if defined
 String getRequestHandler()
           
 Sort getSort()
           
 Integer getTimeAllowed()
          Return the time (in milliseconds) allowed for a search to finish
 boolean hasDefaultOperatorDefined()
           
 void setDefaultOperator(Query.Operator operator)
          Set the default operator q.op for query expressions
 void setDefType(String defType)
          Sets the default type to be used by the query.
 void setJoin(Join join)
          Set values for join {@code !
<T extends Query>
T
setPageRequest(Pageable pageable)
          restrict result to entries on given page.
 void setRequestHandler(String requestHandler)
           
<T extends Query>
T
setTimeAllowed(Integer timeAllowed)
          The time in milliseconds allowed for a search to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.solr.core.query.Query
getRequestHandler, setRequestHandler
 
Methods inherited from interface org.springframework.data.solr.core.query.SolrDataQuery
addCriteria, getCriteria, getJoin, setJoin
 

Field Detail

DEFAULT_PAGE

public static final Pageable DEFAULT_PAGE
Constructor Detail

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,
                   Pageable pageable)
Parameters:
criteria -
pageable -

SimpleQuery

public SimpleQuery(String queryString,
                   Pageable pageable)
Parameters:
queryString -
pageable -
Since:
1.1
Method Detail

fromQuery

public static final Query fromQuery(Query source)

fromQuery

public static <T extends SimpleQuery> T fromQuery(Query source,
                                                  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(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:

addGroupByField

public final <T extends Query> T addGroupByField(Field field)
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

public final <T extends Query> T addGroupByField(String fieldname)
add grouping on fieldname

Parameters:
fieldname - must not be null
Returns:

addSort

public final <T extends Query> T addSort(Sort sort)
Description copied from interface: Query
Add Sort to query

Specified by:
addSort in interface Query
Returns:

getSort

public Sort getSort()
Specified by:
getSort in interface Query
Returns:
null if not set

getPageRequest

public Pageable getPageRequest()
Description copied from interface: Query
Get page settings if defined

Specified by:
getPageRequest in interface Query
Returns:

getGroupByFields

public List<Field> getGroupByFields()
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

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:

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 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

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 -
Returns:

getCriteria

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

Parameters:
from -
to -

getJoin

public Join getJoin()
Returns:
null if not set

getRequestHandler

public String getRequestHandler()

setRequestHandler

public void setRequestHandler(String requestHandler)

Spring Data Solr

Copyright © 2011-2014-2014 Pivotal. All Rights Reserved.