public class DynamicSchemaResolver extends Object
Modifier and Type | Field and Description |
---|---|
protected Set<String> |
anyTextFieldsCache |
protected static String |
COULD_NOT_READ_METACARD_TYPE_MESSAGE |
protected static String |
COULD_NOT_SERIALIZE_OBJECT_MESSAGE |
protected static String |
FIELDS_KEY |
protected Set<String> |
fieldsCache |
protected static char |
FIRST_CHAR_OF_SUFFIX |
static String |
LUX_XML_FIELD_NAME |
protected com.google.common.cache.Cache<String,byte[]> |
metacardTypeNameToSerialCache |
protected com.google.common.cache.Cache<String,MetacardType> |
metacardTypesCache |
protected SchemaFields |
schemaFields |
static String |
SCORE_FIELD_NAME |
static int |
TOKEN_MAXIMUM_BYTES |
protected static XMLInputFactory |
XML_INPUT_FACTORY |
Constructor and Description |
---|
DynamicSchemaResolver() |
DynamicSchemaResolver(List<String> additionalFields) |
Modifier and Type | Method and Description |
---|---|
void |
addFields(Metacard metacard,
org.apache.solr.common.SolrInputDocument solrInputDocument)
Adds the fields of the Metacard into the
SolrInputDocument |
void |
addFieldsFromClient(org.apache.solr.client.solrj.SolrClient client)
Adds the fields that are already in Solr to the cache.
|
Stream<String> |
anyTextFields() |
List<String> |
getAnonymousField(String field)
Attempts to resolve the name of a field without being given an
AttributeType.AttributeFormat |
String |
getCaseSensitiveField(String mappedPropertyName) |
Serializable |
getDocValue(String solrFieldName,
Object docValue) |
List<Serializable> |
getDocValues(String solrFieldName,
Collection<Object> docValues) |
String |
getField(String propertyName,
AttributeType.AttributeFormat format,
boolean isSearchedAsExactValue)
Attempts to find the fieldName for the given propertyName value.
|
String |
getFieldSuffix(AttributeType.AttributeFormat format) |
MetacardType |
getMetacardType(org.apache.solr.common.SolrDocument doc) |
String |
getSortKey(String field) |
protected String |
getSpecialIndexSuffix(AttributeType.AttributeFormat format) |
AttributeType.AttributeFormat |
getType(String solrFieldName)
Returns the best approximation as to what
AttributeType.AttributeFormat this Solr Field is. |
String |
getWhitespaceTokenizedField(String mappedPropertyName) |
boolean |
isPrivateField(String solrFieldName) |
protected List<String> |
parseTextFrom(List<Serializable> xmlDatas)
Given xml as a string, this method will parse out element text and CDATA text.
|
String |
resolveFieldName(String solrFieldName)
PRE-CONDITION is that fieldname cannot be null.
|
public static final String LUX_XML_FIELD_NAME
public static final String SCORE_FIELD_NAME
public static final int TOKEN_MAXIMUM_BYTES
protected static final char FIRST_CHAR_OF_SUFFIX
protected static final String COULD_NOT_READ_METACARD_TYPE_MESSAGE
protected static final String FIELDS_KEY
protected static final String COULD_NOT_SERIALIZE_OBJECT_MESSAGE
protected static final XMLInputFactory XML_INPUT_FACTORY
protected SchemaFields schemaFields
protected com.google.common.cache.Cache<String,MetacardType> metacardTypesCache
protected com.google.common.cache.Cache<String,byte[]> metacardTypeNameToSerialCache
public void addFieldsFromClient(org.apache.solr.client.solrj.SolrClient client)
client
- the SolrClient we are working withpublic void addFields(Metacard metacard, org.apache.solr.common.SolrInputDocument solrInputDocument) throws MetacardCreationException
SolrInputDocument
MetacardCreationException
public AttributeType.AttributeFormat getType(String solrFieldName)
AttributeType.AttributeFormat
this Solr Field is.solrFieldName
- name of the Solr fieldAttributeType.AttributeFormat
associated with the Solr fieldpublic List<Serializable> getDocValues(String solrFieldName, Collection<Object> docValues)
public Serializable getDocValue(String solrFieldName, Object docValue)
public String resolveFieldName(String solrFieldName)
The convention is that we add a suffix starting with an underscore, so if we find the last underscore, then we can return the original field name.
solrFieldName
- Solr index field namepublic boolean isPrivateField(String solrFieldName)
public List<String> getAnonymousField(String field)
AttributeType.AttributeFormat
field
- user given field namepublic String getField(String propertyName, AttributeType.AttributeFormat format, boolean isSearchedAsExactValue)
propertyName
- property name provided by userformat
- AttributeType.AttributeFormat
that describes the type of Attribute
the field isisSearchedAsExactValue
- specifies if any special index suffixes need to be added to the
fieldpublic String getFieldSuffix(AttributeType.AttributeFormat format)
public MetacardType getMetacardType(org.apache.solr.common.SolrDocument doc) throws MetacardCreationException
MetacardCreationException
protected String getSpecialIndexSuffix(AttributeType.AttributeFormat format)
protected List<String> parseTextFrom(List<Serializable> xmlDatas)
xmlDatas
- List of XML as String
This work is licensed under a Creative Commons Attribution 4.0 International License.