@Unstable
@Role
public interface SolrUtils
Modifier and Type | Field and Description |
---|---|
static String |
ATOMIC_UPDATE_MODIFIER_ADD
Adds the specified values to a multiValued field.
|
static String |
ATOMIC_UPDATE_MODIFIER_ADD_DISTINCT
Adds the specified values to a multiValued field, only if not already present.
|
static String |
ATOMIC_UPDATE_MODIFIER_INC
Increments a numeric value by a specific amount.
|
static String |
ATOMIC_UPDATE_MODIFIER_REMOVE
Removes (all occurrences of) the specified values from a multiValued field.
|
static String |
ATOMIC_UPDATE_MODIFIER_REMOVEREGEX
Removes all occurrences of the specified regex from a multiValued field.
|
static String |
ATOMIC_UPDATE_MODIFIER_SET
Set or replace the field value(s) with the specified value(s), or remove the values if 'null' or empty list is
specified as the new value.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
get(String fieldName,
org.apache.solr.common.SolrDocument document)
Extract from the document the value associated with the passed field name.
|
<T> T |
get(String fieldName,
org.apache.solr.common.SolrDocument document,
T def)
Extract from the document the value associated with the passed field name.
|
<T> T |
get(String fieldName,
org.apache.solr.common.SolrDocument document,
Type targetType)
Extract from the document the value associated with the passed field name.
|
<T> Collection<T> |
getCollection(String fieldName,
org.apache.solr.common.SolrDocument document)
Extract from the document the values associated with the passed field name.
|
default <T> Collection<T> |
getCollection(String fieldName,
org.apache.solr.common.SolrDocument document,
Type targetType)
Extract from the document the values associated with the passed field name.
|
String |
getId(org.apache.solr.common.SolrDocument document)
Extract the identifier of the document.
|
<T> List<T> |
getList(String fieldName,
org.apache.solr.common.SolrDocument document)
Extract from the document the values associated with the passed field name.
|
<V> Map<String,V> |
getMap(String fieldName,
org.apache.solr.common.SolrDocument document)
Extract a
Map<String, Object> from the passed SolrDocument . |
default String |
getMapFieldName(String key,
String mapFieldName,
Type type) |
<T> Set<T> |
getSet(String fieldName,
org.apache.solr.common.SolrDocument document)
Extract from the document the values associated with the passed field name.
|
void |
set(String fieldName,
Collection<?> fieldValue,
org.apache.solr.common.SolrInputDocument document)
Store in the document the values associated with the passed field name.
|
void |
set(String fieldName,
Object fieldValue,
org.apache.solr.common.SolrInputDocument document)
Store in the document the value associated with the passed field name.
|
void |
setAtomic(String modifier,
String fieldName,
Object fieldValue,
org.apache.solr.common.SolrInputDocument document)
Store in the document the value associated with the passed field name.
|
default void |
setAtomic(String modifier,
String fieldName,
Object fieldValue,
Type valueType,
org.apache.solr.common.SolrInputDocument document)
Store in the document the value associated with the passed field name.
|
void |
setId(Object fieldValue,
org.apache.solr.common.SolrInputDocument document)
Set the identifier of the document.
|
void |
setMap(String fieldName,
Map<String,?> fieldValue,
org.apache.solr.common.SolrInputDocument document)
Set a
Map<String, Object> in the passed SolrDocument . |
default void |
setString(String fieldName,
Collection<?> fieldValue,
Type valueType,
org.apache.solr.common.SolrInputDocument document) |
void |
setString(String fieldName,
Object fieldValue,
org.apache.solr.common.SolrInputDocument document)
Store in the document the value associated with the passed field name.
|
void |
setString(String fieldName,
Object fieldValue,
Type valueType,
org.apache.solr.common.SolrInputDocument document)
Store in the document the value associated with the passed field name.
|
default String |
toCompleteFilterQueryString(Object fieldValue)
Serialize the value into a string that is a complete query string, i.e., cannot be combined with other strings.
|
default String |
toCompleteFilterQueryString(Object fieldValue,
Type valueType)
Serialize the value into a string that is a complete query string, i.e., cannot be combined with other strings.
|
String |
toFilterQueryString(Object fieldValue)
Serialize the value into a value usable in a Solr filter query.
|
default String |
toFilterQueryString(Object fieldValue,
Type valueType)
Serialize the value into a value usable in a Solr filter query.
|
static final String ATOMIC_UPDATE_MODIFIER_SET
static final String ATOMIC_UPDATE_MODIFIER_ADD
static final String ATOMIC_UPDATE_MODIFIER_ADD_DISTINCT
static final String ATOMIC_UPDATE_MODIFIER_REMOVE
static final String ATOMIC_UPDATE_MODIFIER_REMOVEREGEX
static final String ATOMIC_UPDATE_MODIFIER_INC
<V> Map<String,V> getMap(String fieldName, org.apache.solr.common.SolrDocument document)
Map<String, Object>
from the passed SolrDocument
.
Solr DocumentObjectBinder
has native support for maps, unfortunately it only support maps for which all
entries have the same type (and only String and primitive types). The point of this API is to provide binding for
a generic Map of objects.
This API imply that it exist in the schema dynamic fields of the form <mapname>_*_string
(and
<mapname>_*_boolean
, <mapname>_*_pint
, etc.). Can be done using
AbstractSolrCoreInitializer.addMapField(String)
.
V
- the type of the value in the mapfieldName
- the prefix of the fields containing the map datadocument
- the Solr documentsetMap(String, Map, SolrInputDocument)
void setMap(String fieldName, Map<String,?> fieldValue, org.apache.solr.common.SolrInputDocument document)
Map<String, Object>
in the passed SolrDocument
.fieldName
- the prefix of the fields containing the map datafieldValue
- the map to store in the SolrDocument
document
- the Solr documentgetMap(String, SolrDocument)
default String getMapFieldName(String key, String mapFieldName, Type type)
key
- the key in the mapmapFieldName
- the name of the virtual map fieldtype
- the type of the valueString getId(org.apache.solr.common.SolrDocument document)
document
- the Solr document<T> T get(String fieldName, org.apache.solr.common.SolrDocument document)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr documentvoid setId(Object fieldValue, org.apache.solr.common.SolrInputDocument document)
fieldValue
- the id value to store in the SolrDocument
document
- the Solr documentvoid set(String fieldName, Object fieldValue, org.apache.solr.common.SolrInputDocument document)
fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
document
- the Solr documentvoid setAtomic(String modifier, String fieldName, Object fieldValue, org.apache.solr.common.SolrInputDocument document)
modifier
- the atomic update modifier to apply (set, add, add-distinct, remove, removeregex, inc)fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
document
- the Solr document@Unstable default void setAtomic(String modifier, String fieldName, Object fieldValue, Type valueType, org.apache.solr.common.SolrInputDocument document)
modifier
- the atomic update modifier to apply (set, add, add-distinct, remove, removeregex, inc)fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
valueType
- the type to use as reference to serialize the valuedocument
- the Solr documentvoid set(String fieldName, Collection<?> fieldValue, org.apache.solr.common.SolrInputDocument document)
The field is expected to be multivalued.
fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
document
- the Solr documentvoid setString(String fieldName, Object fieldValue, org.apache.solr.common.SolrInputDocument document)
If the value is not of type String
it's converted automatically.
fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
document
- the Solr documentvoid setString(String fieldName, Object fieldValue, Type valueType, org.apache.solr.common.SolrInputDocument document)
If the value is not of type String
it's converted automatically.
fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
valueType
- the type to use as reference to serialize the valuedocument
- the Solr documentdefault void setString(String fieldName, Collection<?> fieldValue, Type valueType, org.apache.solr.common.SolrInputDocument document)
fieldName
- the name of the field in the documentfieldValue
- the value to store in the SolrDocument
valueType
- the type to use as reference to serialize the valuesdocument
- the Solr documentString toFilterQueryString(Object fieldValue)
fieldValue
- the value of a fielddefault String toFilterQueryString(Object fieldValue, Type valueType)
fieldValue
- the value of a fieldvalueType
- the type to use as reference to serialize the value@Unstable default String toCompleteFilterQueryString(Object fieldValue)
For example, this serializes the empty string as "".
fieldValue
- the value of a field@Unstable default String toCompleteFilterQueryString(Object fieldValue, Type valueType)
For example, this serializes the empty string as "".
fieldValue
- the value of a fieldvalueType
- the type to use as reference to serialize the value<T> T get(String fieldName, org.apache.solr.common.SolrDocument document, Type targetType)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr documenttargetType
- the type of the value to return<T> T get(String fieldName, org.apache.solr.common.SolrDocument document, T def)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr documentdef
- the default value if none is availabledefault <T> Collection<T> getCollection(String fieldName, org.apache.solr.common.SolrDocument document, Type targetType)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr documenttargetType
- the type of the value to return<T> Collection<T> getCollection(String fieldName, org.apache.solr.common.SolrDocument document)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr document<T> Set<T> getSet(String fieldName, org.apache.solr.common.SolrDocument document)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr document<T> List<T> getList(String fieldName, org.apache.solr.common.SolrDocument document)
T
- the of the value to returnfieldName
- the name of the field in the documentdocument
- the Solr documentCopyright © 2004–2022 XWiki. All rights reserved.