org.apache.solr.client.solrj
Class SolrQuery

java.lang.Object
  extended by org.apache.solr.common.params.SolrParams
      extended by org.apache.solr.common.params.ModifiableSolrParams
          extended by org.apache.solr.client.solrj.SolrQuery
All Implemented Interfaces:
Serializable

public class SolrQuery
extends org.apache.solr.common.params.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 682587 2008-08-05 05:43:59Z shalin $
See Also:
Serialized Form

Nested Class Summary
static class SolrQuery.ORDER
           
 
Constructor Summary
SolrQuery()
           
SolrQuery(String q)
          Create a new SolrQuery
 
Method Summary
 SolrQuery addFacetField(String... fields)
          add a field 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 addSortField(String field, SolrQuery.ORDER order)
           
 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()
          get facet sort
 String getFields()
           
 String[] getFilterQueries()
           
 boolean getHighlight()
           
 String[] getHighlightFields()
          get list of hl fields
 int getHighlightFragsize()
           
 String getHighlightSimplePost()
           
 String getHighlightSimplePre()
           
 int getHighlightSnippets()
           
 String getQuery()
           
 String getQueryType()
           
 Integer getRows()
           
 String getSortField()
           
 String[] getSortFields()
           
 Integer getStart()
           
 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)
          se the facet limit
 SolrQuery setFacetMinCount(int cnt)
          set facet minimum count
 SolrQuery setFacetPrefix(String prefix)
           
 SolrQuery setFacetPrefix(String field, String prefix)
           
 SolrQuery setFacetSort(Boolean sort)
          set facet sort
 SolrQuery setFields(String... fields)
           
 SolrQuery setFilterQueries(String... fq)
           
 SolrQuery setHighlight(boolean b)
           
 SolrQuery setHighlightFragsize(int num)
           
 boolean setHighlightRequireFieldMatch()
           
 SolrQuery setHighlightRequireFieldMatch(boolean flag)
           
 SolrQuery setHighlightSimplePost(String f)
           
 SolrQuery setHighlightSimplePre(String f)
           
 SolrQuery setHighlightSnippets(int num)
           
 SolrQuery setIncludeScore(boolean includeScore)
           
 SolrQuery setMissing(String fld)
           
 SolrQuery setParam(String name, boolean value)
           
 SolrQuery setParam(String name, String... values)
           
 SolrQuery setQuery(String query)
           
 SolrQuery setQueryType(String qt)
           
 SolrQuery setRows(Integer rows)
           
 void setShowDebugInfo(boolean showDebugInfo)
           
 SolrQuery setSortField(String field, SolrQuery.ORDER order)
           
 SolrQuery setStart(Integer start)
           
 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, getFieldBool, getFieldBool, getFieldFloat, getFieldFloat, getFieldInt, getFieldInt, getFieldParam, getFieldParam, getFieldParams, getFloat, getFloat, getInt, getInt, parseBool, required, toMap, toMultiMap, toNamedList, toSolrParams
 
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

addFacetField

public SolrQuery addFacetField(String... fields)
add a field for facet computation

Parameters:
fields - the field name from the IndexSchema
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


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:
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)
se 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

setMissing

public SolrQuery setMissing(String fld)

getFacetSort

public boolean getFacetSort()
get facet sort

Returns:
facet sort or default of true

setFacetSort

public SolrQuery setFacetSort(Boolean sort)
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 hl fields

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

setHighlightRequireFieldMatch

public boolean setHighlightRequireFieldMatch()

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

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)

getQueryType

public String getQueryType()

setParam

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

setParam

public SolrQuery setParam(String name,
                          boolean value)

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.



Copyright © 2008 Apache Software Foundation. All Rights Reserved.