public class CmsSolrQuery extends org.apache.solr.client.solrj.SolrQuery
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ALL_RETURN_FIELDS
A constant to add the score field to the result documents.
|
static java.lang.String |
DEFAULT_FACET_DATE_GAP
The default facet date gap.
|
static java.lang.String |
DEFAULT_QUERY
The default query.
|
static java.lang.String |
DEFAULT_QUERY_TYPE
The query type.
|
static java.lang.Integer |
DEFAULT_ROWS
The default search result count.
|
static java.lang.String |
MINIMUM_FIELDS
A constant to add the score field to the result documents.
|
static java.lang.String |
STRUCTURE_FIELDS
A constant to add the score field to the result documents.
|
| Constructor and Description |
|---|
CmsSolrQuery()
Default constructor.
|
CmsSolrQuery(CmsObject cms,
java.util.Map<java.lang.String,java.lang.String[]> queryParams)
Public constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFilterQuery(java.lang.String fieldName,
java.util.List<java.lang.String> vals,
boolean all,
boolean useQuotes)
Creates and adds a filter query.
|
void |
addSortFieldOrders(java.util.Map<java.lang.String,org.apache.solr.client.solrj.SolrQuery.ORDER> sortFields)
Adds the given fields/orders to the existing sort fields.
|
CmsSolrQuery |
clone() |
void |
ensureParameters()
Ensures that the initial request parameters will overwrite the member values.
|
static java.lang.String |
getResourceType(java.lang.String[] fqs)
Returns the resource type if only one is set as filter query.
|
void |
removeExpiration()
Removes the expiration flag.
|
void |
setCategories(java.util.List<java.lang.String> categories)
Sets the categories only if not set in the query parameters.
|
void |
setCategories(java.lang.String... categories)
Sets the categories only if not set in the query parameters.
|
void |
setDateRanges(java.util.Map<java.lang.String,CmsPair<java.util.Date,java.util.Date>> dateRanges)
Sets date ranges.
|
void |
setFacetDateGap(java.lang.String facetDateGap)
Sets the facetDateGap.
|
void |
setHighlightFields(java.util.List<java.lang.String> highlightFields)
Sets the highlightFields.
|
void |
setHighlightFields(java.lang.String... highlightFields)
Sets the highlightFields.
|
void |
setLocales(java.util.List<java.util.Locale> locales)
Sets the locales only if not set in the query parameters.
|
void |
setLocales(java.util.Locale... locales)
Sets the locales only if not set in the query parameters.
|
org.apache.solr.client.solrj.SolrQuery |
setRequestHandler(java.lang.String qt) |
void |
setResourceTypes(java.util.List<java.lang.String> resourceTypes)
Sets the resource types only if not set in the query parameters.
|
void |
setResourceTypes(java.lang.String... resourceTypes)
Sets the resource types only if not set in the query parameters.
|
void |
setReturnFields(java.lang.String returnFields)
Sets the requested return fields, but ensures that at least the 'path' and the 'type', 'id' and 'solr_id'
are part of the fields returned field list.
|
void |
setSearchRoots(java.util.List<java.lang.String> searchRoots)
Sets the search roots only if not set as query parameter.
|
void |
setSearchRoots(java.lang.String... searchRoots)
Sets the search roots only if not set as query parameter.
|
void |
setStructureQuery(boolean structureQuery)
Sets the return fields 'fl' to a predefined set that does not contain content specific fields.
|
void |
setText(java.lang.String text)
Sets the text.
|
void |
setTextSearchFields(java.util.List<java.lang.String> textSearchFields)
Sets the textSearchFields.
|
void |
setTextSearchFields(java.lang.String... textSearchFields)
Sets the textSearchFields.
|
java.lang.String |
toString() |
addDateRangeFacet, addFacetField, addFacetPivotField, addFacetQuery, addField, addFilterQuery, addGetFieldStatistics, addHighlightField, addIntervalFacets, addMoreLikeThisField, addNumericRangeFacet, addOrUpdateSort, addOrUpdateSort, addSort, addSort, addStatsFieldCalcDistinct, addStatsFieldFacets, addTermsField, clearSorts, getCopy, getFacetFields, getFacetLimit, getFacetMinCount, getFacetQuery, getFacetSortString, getFields, getFilterQueries, getHighlight, getHighlightFields, getHighlightFragsize, getHighlightRequireFieldMatch, getHighlightSimplePost, getHighlightSimplePre, getHighlightSnippets, getMoreLikeThis, getMoreLikeThisBoost, getMoreLikeThisCount, getMoreLikeThisFields, getMoreLikeThisMaxQueryTerms, getMoreLikeThisMaxTokensParsed, getMoreLikeThisMaxWordLen, getMoreLikeThisMinDocFreq, getMoreLikeThisMinTermFreq, getMoreLikeThisMinWordLen, getMoreLikeThisQF, getQuery, getRequestHandler, getRows, getSortField, getSorts, getStart, getTerms, getTermsFields, getTermsLimit, getTermsLower, getTermsLowerInclusive, getTermsMaxCount, getTermsMinCount, getTermsPrefix, getTermsRaw, getTermsRegex, getTermsRegexFlags, getTermsSortString, getTermsUpper, getTermsUpperInclusive, getTimeAllowed, removeFacetField, removeFacetQuery, removeFilterQuery, removeHighlightField, removeIntervalFacets, removeSort, removeSort, setDistrib, setFacet, setFacetLimit, setFacetMinCount, setFacetMissing, setFacetPrefix, setFacetPrefix, setFacetSort, setFields, setFilterQueries, setGetFieldStatistics, setGetFieldStatistics, setHighlight, setHighlightFragsize, setHighlightRequireFieldMatch, setHighlightSimplePost, setHighlightSimplePre, setHighlightSnippets, setIncludeScore, setMoreLikeThis, setMoreLikeThisBoost, setMoreLikeThisCount, setMoreLikeThisFields, setMoreLikeThisMaxQueryTerms, setMoreLikeThisMaxTokensParsed, setMoreLikeThisMaxWordLen, setMoreLikeThisMinDocFreq, setMoreLikeThisMinTermFreq, setMoreLikeThisMinWordLen, setMoreLikeThisQF, setParam, setParam, setQuery, setRows, setShowDebugInfo, setSort, setSort, setSorts, setStart, setTerms, setTermsLimit, setTermsLower, setTermsLowerInclusive, setTermsMaxCount, setTermsMinCount, setTermsPrefix, setTermsRaw, setTermsRegex, setTermsRegexFlag, setTermsSortString, setTermsUpper, setTermsUpperInclusive, setTimeAllowedadd, add, clear, get, getMap, getParameterNames, getParameterNamesIterator, getParams, iterator, of, remove, remove, set, set, set, setNonNull, sizefpname, get, getAll, getAll, getBool, getBool, getDouble, getDouble, getFieldBool, getFieldBool, getFieldDouble, getFieldDouble, getFieldFloat, getFieldFloat, getFieldInt, getFieldInt, getFieldParam, getFieldParam, getFieldParams, getFloat, getFloat, getInt, getInt, getLong, getLong, getPrimitiveBool, getPrimitiveFieldBool, getPrimitiveFieldFloat, getPrimitiveInt, required, stream, toFilteredSolrParams, toLocalParamsString, toMap, toMultiMap, toNamedList, toQueryString, toSolrParams, wrapAppended, wrapDefaults, writeMapequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static final java.lang.String ALL_RETURN_FIELDS
public static final java.lang.String DEFAULT_FACET_DATE_GAP
public static final java.lang.String DEFAULT_QUERY
public static final java.lang.String DEFAULT_QUERY_TYPE
public static final java.lang.Integer DEFAULT_ROWS
public static final java.lang.String MINIMUM_FIELDS
public static final java.lang.String STRUCTURE_FIELDS
public CmsSolrQuery()
public CmsSolrQuery(CmsObject cms, java.util.Map<java.lang.String,java.lang.String[]> queryParams)
cms - the current OpenCms contextqueryParams - the Solr query parameterspublic static java.lang.String getResourceType(java.lang.String[] fqs)
fqs - the field queries to checknullpublic void addFilterQuery(java.lang.String fieldName, java.util.List<java.lang.String> vals, boolean all, boolean useQuotes)
fieldName - the field name to create a filter query onvals - the values that should match for the given fieldall - true to combine the given values with 'AND', false for 'OR'useQuotes - true to surround the given values with double quotes, false otherwisepublic void addSortFieldOrders(java.util.Map<java.lang.String,org.apache.solr.client.solrj.SolrQuery.ORDER> sortFields)
sortFields - the sortFields to setpublic CmsSolrQuery clone()
clone in class java.lang.ObjectObject.clone()public void ensureParameters()
You can initialize the query with an HTTP request parameter then make some method calls and finally re-ensure that the initial request parameters will overwrite the changes made in the meanwhile.
public void removeExpiration()
public void setCategories(java.util.List<java.lang.String> categories)
categories - the categories to setpublic void setCategories(java.lang.String... categories)
categories - the categories to setpublic void setDateRanges(java.util.Map<java.lang.String,CmsPair<java.util.Date,java.util.Date>> dateRanges)
This call will overwrite all existing date ranges for the given keys (name of the date facet field).
The parameter Map uses as:
keys: Solr field name CmsSearchField and
values: pairs with min date as first and max date as second CmsPair
+created:[* TO NOW]
+lastmodified:[' + date + ' TO NOW]
CmsSearchUtil.getDateAsIso8601(Date)
dateRanges - the ranges map with field name as key and a CmsPair with min date as first and max date as secondpublic void setFacetDateGap(java.lang.String facetDateGap)
facetDateGap - the facetDateGap to setpublic void setHighlightFields(java.util.List<java.lang.String> highlightFields)
highlightFields - the highlightFields to setpublic void setHighlightFields(java.lang.String... highlightFields)
highlightFields - the highlightFields to setpublic void setLocales(java.util.List<java.util.Locale> locales)
locales - the locales to setpublic void setLocales(java.util.Locale... locales)
locales - the locales to setpublic org.apache.solr.client.solrj.SolrQuery setRequestHandler(java.lang.String qt)
setRequestHandler in class org.apache.solr.client.solrj.SolrQuerySolrQuery.setRequestHandler(java.lang.String)public void setResourceTypes(java.util.List<java.lang.String> resourceTypes)
resourceTypes - the resourceTypes to setpublic void setResourceTypes(java.lang.String... resourceTypes)
resourceTypes - the resourceTypes to setpublic void setReturnFields(java.lang.String returnFields)
returnFields - the really requested return fields.CommonParams.FLpublic void setSearchRoots(java.util.List<java.lang.String> searchRoots)
searchRoots - the searchRoots to setpublic void setSearchRoots(java.lang.String... searchRoots)
searchRoots - the searchRoots to setpublic void setStructureQuery(boolean structureQuery)
structureQuery - the true to return only structural fieldspublic void setText(java.lang.String text)
text - the text to setpublic void setTextSearchFields(java.util.List<java.lang.String> textSearchFields)
textSearchFields - the textSearchFields to setpublic void setTextSearchFields(java.lang.String... textSearchFields)
textSearchFields - the textSearchFields to setpublic java.lang.String toString()
toString in class org.apache.solr.common.params.SolrParamsSolrParams.toString()