SolrQuery (Solr 3.6.2 API)
Keywords: org.apache.solr.client.solrj.SolrQuery class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.client.solrj
Class SolrQuery

    java.lang.Object
      org.apache.solr.common.params.SolrParams
          org.apache.solr.common.params.ModifiableSolrParams
              org.apache.solr.client.solrj.SolrQuery

All Implemented Interfaces:
  Serializable

    public class SolrQuery

extends ModifiableSolrParams

This is an augmented SolrParams with get/set/add fields for common fields used in the Standard and Dismax request handlers

Since:
  solr 1.3
Version:
  $Id: SolrQuery.java 1150364 2011-07-24 13:45:16Z mvg $
See Also:
  Serialized Form

Nested Class Summary
`static class` | `SolrQuery.ORDER`

Constructor Summary
`SolrQuery()`
`SolrQuery(String q)` Create a new SolrQuery

Method Summary
`SolrQuery` | `addDateRangeFacet(String field, Date start, Date end, String gap)` Add a numeric range facet.
`SolrQuery` | `addFacetField(String... fields)` Add field(s) for facet computation.
`SolrQuery` | `addFacetQuery(String f)` add a faceting query
`SolrQuery` | `addField(String field)`
`SolrQuery` | `addFilterQuery(String... fq)`
`SolrQuery` | `addHighlightField(String f)` add highlight field
`SolrQuery` | `addNumericRangeFacet(String field, Number start, Number end, Number gap)` Add a numeric range facet.
`SolrQuery` | `addSortField(String field, SolrQuery.ORDER order)`
`void` | `addStatsFieldFacets(String field, String... facets)`
`SolrQuery` | `addTermsField(String field)`
`SolrQuery` | `getCopy()` get a deep copy of this object
`String[]` | `getFacetFields()` get the facet fields
`int` | `getFacetLimit()` get current facet limit
`int` | `getFacetMinCount()` get facet minimum count
`String[]` | `getFacetQuery()` get facet queries
`boolean` | `getFacetSort()` Deprecated. Use `getFacetSortString()` instead.
`String` | `getFacetSortString()` get facet sort
`String` | `getFields()`
`String[]` | `getFilterQueries()`
`boolean` | `getHighlight()`
`String[]` | `getHighlightFields()` get list of highlighted fields
`int` | `getHighlightFragsize()`
`boolean` | `getHighlightRequireFieldMatch()`
`String` | `getHighlightSimplePost()`
`String` | `getHighlightSimplePre()`
`int` | `getHighlightSnippets()`
`String` | `getQuery()`
`String` | `getQueryType()`
`Integer` | `getRows()`
`String` | `getSortField()`
`String[]` | `getSortFields()`
`Integer` | `getStart()`
`boolean` | `getTerms()`
`String[]` | `getTermsFields()`
`int` | `getTermsLimit()`
`String` | `getTermsLower()`
`boolean` | `getTermsLowerInclusive()`
`int` | `getTermsMaxCount()`
`int` | `getTermsMinCount()`
`String` | `getTermsPrefix()`
`boolean` | `getTermsRaw()`
`String` | `getTermsRegex()`
`String[]` | `getTermsRegexFlags()`
`String` | `getTermsSortString()`
`String` | `getTermsUpper()`
`boolean` | `getTermsUpperInclusive()`
`Integer` | `getTimeAllowed()` Get the maximum time allowed for this query.
`boolean` | `removeFacetField(String name)` remove a facet field
`boolean` | `removeFacetQuery(String q)` remove a facet query
`boolean` | `removeFilterQuery(String fq)`
`boolean` | `removeHighlightField(String f)` remove a field for highlighting
`SolrQuery` | `removeSortField(String field, SolrQuery.ORDER order)`
`SolrQuery` | `setFacet(boolean b)` enable/disable faceting.
`SolrQuery` | `setFacetLimit(int lim)` set the facet limit
`SolrQuery` | `setFacetMinCount(int cnt)` set facet minimum count
`SolrQuery` | `setFacetMissing(Boolean v)` Sets facet missing boolean flag
`SolrQuery` | `setFacetPrefix(String prefix)`
`SolrQuery` | `setFacetPrefix(String field, String prefix)`
`SolrQuery` | `setFacetSort(boolean sort)` Deprecated. Use `setFacetSort(String)` instead, true corresponds to `FacetParams.FACET_SORT_COUNT` and false to `FacetParams.FACET_SORT_INDEX`.
`SolrQuery` | `setFacetSort(String sort)` set facet sort
`SolrQuery` | `setFields(String... fields)`
`SolrQuery` | `setFilterQueries(String... fq)`
`void` | `setGetFieldStatistics(boolean v)`
`void` | `setGetFieldStatistics(String field)`
`SolrQuery` | `setHighlight(boolean b)`
`SolrQuery` | `setHighlightFragsize(int num)`
`SolrQuery` | `setHighlightRequireFieldMatch(boolean flag)`
`SolrQuery` | `setHighlightSimplePost(String f)`
`SolrQuery` | `setHighlightSimplePre(String f)`
`SolrQuery` | `setHighlightSnippets(int num)`
`SolrQuery` | `setIncludeScore(boolean includeScore)`
`SolrQuery` | `setMissing(String fld)` Deprecated. use `setFacetMissing(Boolean)`
`SolrQuery` | `setParam(String name, boolean value)`
`SolrQuery` | `setParam(String name, String... values)`
`SolrQuery` | `setQuery(String query)`
`SolrQuery` | `setQueryType(String qt)` Query type used to determine the request handler.
`SolrQuery` | `setRows(Integer rows)`
`void` | `setShowDebugInfo(boolean showDebugInfo)`
`SolrQuery` | `setSortField(String field, SolrQuery.ORDER order)`
`SolrQuery` | `setStart(Integer start)`
`SolrQuery` | `setTerms(boolean b)` enable/disable terms.
`SolrQuery` | `setTermsLimit(int limit)`
`SolrQuery` | `setTermsLower(String lower)`
`SolrQuery` | `setTermsLowerInclusive(boolean b)`
`SolrQuery` | `setTermsMaxCount(int cnt)`
`SolrQuery` | `setTermsMinCount(int cnt)`
`SolrQuery` | `setTermsPrefix(String prefix)`
`SolrQuery` | `setTermsRaw(boolean b)`
`SolrQuery` | `setTermsRegex(String regex)`
`SolrQuery` | `setTermsRegexFlag(String flag)`
`SolrQuery` | `setTermsSortString(String type)`
`SolrQuery` | `setTermsUpper(String upper)`
`SolrQuery` | `setTermsUpperInclusive(boolean b)`
`SolrQuery` | `setTimeAllowed(Integer milliseconds)` Set the maximum time allowed for this query.

Methods inherited from class org.apache.solr.common.params.ModifiableSolrParams
`add, add, clear, get, getParameterNames, getParameterNamesIterator, getParams, remove, remove, set, set, set, toString`

Methods inherited from class org.apache.solr.common.params.SolrParams
`fpname, get, getBool, getBool, getDouble, getDouble, getFieldBool, getFieldBool, getFieldDouble, getFieldDouble, getFieldFloat, getFieldFloat, getFieldInt, getFieldInt, getFieldParam, getFieldParam, getFieldParams, getFloat, getFloat, getInt, getInt, parseBool, required, toMap, toMultiMap, toNamedList, toSolrParams, wrapAppended, wrapDefaults`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SolrQuery

    public SolrQuery()

### SolrQuery

    public SolrQuery(String q)

  Create a new SolrQuery

  Parameters:
    `q` - query string

Method Detail

### setTerms

    public SolrQuery setTerms(boolean b)

  enable/disable terms.

  Parameters:
    `b` - flag to indicate terms should be enabled.
    if b==false, removes all other terms parameters
  Returns:
    Current reference (this)

### getTerms

    public boolean getTerms()

### addTermsField

    public SolrQuery addTermsField(String field)

### getTermsFields

    public String[] getTermsFields()

### setTermsLower

    public SolrQuery setTermsLower(String lower)

### getTermsLower

    public String getTermsLower()

### setTermsUpper

    public SolrQuery setTermsUpper(String upper)

### getTermsUpper

    public String getTermsUpper()

### setTermsUpperInclusive

    public SolrQuery setTermsUpperInclusive(boolean b)

### getTermsUpperInclusive

    public boolean getTermsUpperInclusive()

### setTermsLowerInclusive

    public SolrQuery setTermsLowerInclusive(boolean b)

### getTermsLowerInclusive

    public boolean getTermsLowerInclusive()

### setTermsLimit

    public SolrQuery setTermsLimit(int limit)

### getTermsLimit

    public int getTermsLimit()

### setTermsMinCount

    public SolrQuery setTermsMinCount(int cnt)

### getTermsMinCount

    public int getTermsMinCount()

### setTermsMaxCount

    public SolrQuery setTermsMaxCount(int cnt)

### getTermsMaxCount

    public int getTermsMaxCount()

### setTermsPrefix

    public SolrQuery setTermsPrefix(String prefix)

### getTermsPrefix

    public String getTermsPrefix()

### setTermsRaw

    public SolrQuery setTermsRaw(boolean b)

### getTermsRaw

    public boolean getTermsRaw()

### setTermsSortString

    public SolrQuery setTermsSortString(String type)

### getTermsSortString

    public String getTermsSortString()

### setTermsRegex

    public SolrQuery setTermsRegex(String regex)

### getTermsRegex

    public String getTermsRegex()

### setTermsRegexFlag

    public SolrQuery setTermsRegexFlag(String flag)

### getTermsRegexFlags

    public String[] getTermsRegexFlags()

### addFacetField

    public SolrQuery addFacetField(String... fields)

  Add field(s) for facet computation.

  Parameters:
    `fields` - Array of field names from the IndexSchema
  Returns:
    this

### addNumericRangeFacet

    public SolrQuery addNumericRangeFacet(String field,
                                          Number start,
                                          Number end,
                                          Number gap)

  Add a numeric range facet.

  Parameters:
    `field` - The field
    `start` - The start of range
    `end` - The end of the range
    `gap` - The gap between each count
  Returns:
    this

### addDateRangeFacet

    public SolrQuery addDateRangeFacet(String field,
                                       Date start,
                                       Date end,
                                       String gap)

  Add a numeric range facet.

  Parameters:
    `field` - The field
    `start` - The start of range
    `end` - The end of the range
    `gap` - The gap between each count
  Returns:
    this

### getFacetFields

    public String[] getFacetFields()

  get the facet fields

  Returns:
    string array of facet fields or null if not set/empty

### removeFacetField

    public boolean removeFacetField(String name)

  remove a facet field

  Parameters:
    `name` - Name of the facet field to be removed.
  Returns:
    true, if the item was removed.
    false, if the facet field was null or did not exist.

### setFacet

    public SolrQuery setFacet(boolean b)

  enable/disable faceting.

  Parameters:
    `b` - flag to indicate faceting should be enabled.
    if b==false, removes all other faceting parameters
  Returns:
    Current reference (this)

### setFacetPrefix

    public SolrQuery setFacetPrefix(String prefix)

### setFacetPrefix

    public SolrQuery setFacetPrefix(String field,
                                    String prefix)

### addFacetQuery

    public SolrQuery addFacetQuery(String f)

  add a faceting query

  Parameters:
    `f` - facet query

### getFacetQuery

    public String[] getFacetQuery()

  get facet queries

  Returns:
    all facet queries or null if not set/empty

### removeFacetQuery

    public boolean removeFacetQuery(String q)

  remove a facet query

  Parameters:
    `q` - the facet query to remove
  Returns:
    true if the facet query was removed false otherwise

### setFacetLimit

    public SolrQuery setFacetLimit(int lim)

  set the facet limit

  Parameters:
    `lim` - number facet items to return

### getFacetLimit

    public int getFacetLimit()

  get current facet limit

  Returns:
    facet limit or default of 25

### setFacetMinCount

    public SolrQuery setFacetMinCount(int cnt)

  set facet minimum count

  Parameters:
    `cnt` - facets having less that cnt hits will be excluded from teh facet list

### getFacetMinCount

    public int getFacetMinCount()

  get facet minimum count

  Returns:
    facet minimum count or default of 1

### setFacetMissing

    public SolrQuery setFacetMissing(Boolean v)

  Sets facet missing boolean flag

  Parameters:
    `v` - flag to indicate the field of `FacetParams.FACET_MISSING` .
  Returns:
    this

### setMissing

    @Deprecated
    public SolrQuery setMissing(String fld)

  Deprecated. use `setFacetMissing(Boolean)`

### getFacetSortString

    public String getFacetSortString()

  get facet sort

  Returns:
    facet sort or default of `FacetParams.FACET_SORT_COUNT`

### getFacetSort

    @Deprecated
    public boolean getFacetSort()

  Deprecated. Use `getFacetSortString()` instead.

  get facet sort

  Returns:
    facet sort or default of true.
    true corresponds to `FacetParams.FACET_SORT_COUNT` and
    false to `FacetParams.FACET_SORT_INDEX`

### setFacetSort

    public SolrQuery setFacetSort(String sort)

  set facet sort

  Parameters:
    `sort` - sort facets
  Returns:
    this

### setFacetSort

    @Deprecated
    public SolrQuery setFacetSort(boolean sort)

  Deprecated. Use `setFacetSort(String)` instead, true corresponds to `FacetParams.FACET_SORT_COUNT` and false to `FacetParams.FACET_SORT_INDEX`.

  set facet sort

  Parameters:
    `sort` - sort facets
  Returns:
    this

### addHighlightField

    public SolrQuery addHighlightField(String f)

  add highlight field

  Parameters:
    `f` - field to enable for highlighting

### removeHighlightField

    public boolean removeHighlightField(String f)

  remove a field for highlighting

  Parameters:
    `f` - field name to not highlight
  Returns:
    true, if removed,
    false, otherwise

### getHighlightFields

    public String[] getHighlightFields()

  get list of highlighted fields

  Returns:
    Array of highlight fields or null if not set/empty

### setHighlightSnippets

    public SolrQuery setHighlightSnippets(int num)

### getHighlightSnippets

    public int getHighlightSnippets()

### setHighlightFragsize

    public SolrQuery setHighlightFragsize(int num)

### getHighlightFragsize

    public int getHighlightFragsize()

### setHighlightRequireFieldMatch

    public SolrQuery setHighlightRequireFieldMatch(boolean flag)

### getHighlightRequireFieldMatch

    public boolean getHighlightRequireFieldMatch()

### setHighlightSimplePre

    public SolrQuery setHighlightSimplePre(String f)

### getHighlightSimplePre

    public String getHighlightSimplePre()

### setHighlightSimplePost

    public SolrQuery setHighlightSimplePost(String f)

### getHighlightSimplePost

    public String getHighlightSimplePost()

### setSortField

    public SolrQuery setSortField(String field,
                                  SolrQuery.ORDER order)

### addSortField

    public SolrQuery addSortField(String field,
                                  SolrQuery.ORDER order)

### removeSortField

    public SolrQuery removeSortField(String field,
                                     SolrQuery.ORDER order)

### getSortFields

    public String[] getSortFields()

### getSortField

    public String getSortField()

### setGetFieldStatistics

    public void setGetFieldStatistics(boolean v)

### setGetFieldStatistics

    public void setGetFieldStatistics(String field)

### addStatsFieldFacets

    public void addStatsFieldFacets(String field,
                                    String... facets)

### setFilterQueries

    public SolrQuery setFilterQueries(String... fq)

### addFilterQuery

    public SolrQuery addFilterQuery(String... fq)

### removeFilterQuery

    public boolean removeFilterQuery(String fq)

### getFilterQueries

    public String[] getFilterQueries()

### getHighlight

    public boolean getHighlight()

### setHighlight

    public SolrQuery setHighlight(boolean b)

### setFields

    public SolrQuery setFields(String... fields)

### addField

    public SolrQuery addField(String field)

### getFields

    public String getFields()

### setIncludeScore

    public SolrQuery setIncludeScore(boolean includeScore)

### setQuery

    public SolrQuery setQuery(String query)

### getQuery

    public String getQuery()

### setRows

    public SolrQuery setRows(Integer rows)

### getRows

    public Integer getRows()

### setShowDebugInfo

    public void setShowDebugInfo(boolean showDebugInfo)

### setStart

    public SolrQuery setStart(Integer start)

### getStart

    public Integer getStart()

### setQueryType

    public SolrQuery setQueryType(String qt)

  Query type used to determine the request handler.

  Parameters:
    `qt` - Query Type that corresponds to the query request handler on the server.
  Returns:
    this
  See Also:
    `QueryRequest.getPath()`

### getQueryType

    public String getQueryType()

### setParam

    public SolrQuery setParam(String name,
                              String... values)

  Parameters:
    `name` -
    `values` -
  Returns:
    this
  See Also:
    `ModifiableSolrParams.set(String,String[])`

### setParam

    public SolrQuery setParam(String name,
                              boolean value)

  Parameters:
    `name` -
    `value` -
  Returns:
    this
  See Also:
    `ModifiableSolrParams.set(String, boolean)`

### getCopy

    public SolrQuery getCopy()

  get a deep copy of this object

### setTimeAllowed

    public SolrQuery setTimeAllowed(Integer milliseconds)

  Set the maximum time allowed for this query. If the query takes more time than the specified milliseconds, a timeout occurs and partial (or no) results may be returned. If given Integer is null, then this parameter is removed from the request

  Parameters:
    `milliseconds` - the time in milliseconds allowed for this query

### getTimeAllowed

    public Integer getTimeAllowed()

  Get the maximum time allowed for this query.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD