Package org.alfresco.solr
Class AlfrescoSolrDataModel
- java.lang.Object
-
- org.alfresco.solr.AlfrescoSolrDataModel
-
- All Implemented Interfaces:
org.alfresco.repo.search.adaptor.QueryConstants
public class AlfrescoSolrDataModel extends java.lang.Object implements org.alfresco.repo.search.adaptor.QueryConstants- Author:
- Andy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAlfrescoSolrDataModel.FieldInstancestatic classAlfrescoSolrDataModel.FieldUsestatic classAlfrescoSolrDataModel.IndexedFieldstatic classAlfrescoSolrDataModel.SpecializedFieldTypestatic classAlfrescoSolrDataModel.TenantDbId
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONTENT_S_LOCALE_PREFIXstatic java.lang.StringDEFAULT_TENANTprotected static org.slf4j.Loggerlog-
Fields inherited from interface org.alfresco.repo.search.adaptor.QueryConstants
FIELD_ACLID, FIELD_ACLTXCOMMITTIME, FIELD_ACLTXID, FIELD_ALL, FIELD_ANAME, FIELD_ANCESTOR, FIELD_APATH, FIELD_ASPECT, FIELD_ASSOCTYPEQNAME, FIELD_AUTHORITY, FIELD_AUTHORITYSET, FIELD_CASCADE_FLAG, FIELD_CASCADETX, FIELD_CLASS, FIELD_CONTENT_DOC_ID_SUFFIX, FIELD_DBID, FIELD_DENIED, FIELD_DENYSET, FIELD_DOC_TYPE, FIELD_ENCODING_SUFFIX, FIELD_EXACTASPECT, FIELD_EXACTTYPE, FIELD_EXCEPTION_MESSAGE, FIELD_EXCEPTION_STACK, FIELD_EXISTS, FIELD_FIELDS, FIELD_FINGERPRINT, FIELD_FTSREF, FIELD_FTSSTATUS, FIELD_GEO, FIELD_ID, FIELD_INACLTXID, FIELD_INTXID, FIELD_ISCATEGORY, FIELD_ISCONTAINER, FIELD_ISNODE, FIELD_ISNOTNULL, FIELD_ISNULL, FIELD_ISROOT, FIELD_ISUNSET, FIELD_LID, FIELD_LINKASPECT, FIELD_LOCALE_SUFFIX, FIELD_MIMETYPE_SUFFIX, FIELD_NO_LOCALE_SUFFIX, FIELD_NPATH, FIELD_NULLPROPERTIES, FIELD_OWNER, FIELD_OWNERSET, FIELD_PARENT, FIELD_PARENT_ASSOC_CRC, FIELD_PATH, FIELD_PATHWITHREPEATS, FIELD_PNAME, FIELD_PRIMARYASSOCQNAME, FIELD_PRIMARYASSOCTYPEQNAME, FIELD_PRIMARYPARENT, FIELD_PROPERTIES, FIELD_QNAME, FIELD_READER, FIELD_READERSET, FIELD_S_ACLTXCOMMITTIME, FIELD_S_ACLTXID, FIELD_S_INACLTXID, FIELD_S_INTXID, FIELD_S_TXCOMMITTIME, FIELD_S_TXID, FIELD_SITE, FIELD_SIZE_SUFFIX, FIELD_SOLR_LOCALISED_UNTOKENISED_SUFFIX, FIELD_SOLR_NOLOCALE_TOKENISED_SUFFIX, FIELD_SOLR_NOLOCALE_UNTOKENISED_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_DAY_OF_WEEK_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_DAY_OF_YEAR_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_DAY_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_HOUR_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_MINUTE_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_MONTH_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_QUARTER_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_SECOND_SUFFIX, FIELD_SOLR_UNIT_OF_TIME_YEAR_SUFFIX, FIELD_SOLR4_ID, FIELD_SORT_SUFFIX, FIELD_TAG, FIELD_TAG_SUGGEST, FIELD_TENANT, FIELD_TEXT, FIELD_TRANSFORMATION_EXCEPTION_SUFFIX, FIELD_TRANSFORMATION_STATUS_SUFFIX, FIELD_TRANSFORMATION_TIME_SUFFIX, FIELD_TX, FIELD_TXCOMMITTIME, FIELD_TXID, FIELD_TYPE, FIELD_VERSION, PROPERTY_FIELD_PREFIX
-
-
Constructor Summary
Constructors Constructor Description AlfrescoSolrDataModel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterInitModels()voidclose()static AlfrescoSolrDataModel.TenantDbIddecodeNodeDocumentId(java.lang.String id)Destructures a document identifier in the three compounding parts (tenant and dbid).java.lang.StringdestructuredDateTimePartFieldNamePrefix(java.lang.String sourceFieldName)Returns the prefix used for denoting a field which is meant to represent a constituent part of a date or datetime (e.g.static java.lang.StringgetAclChangeSetDocumentId(java.lang.Long aclChangeSetId)Returns the ACL ChangeSet Document identifier in the following format TRACKER!CHANGESET!<ACL_CHANGESET_ID>static java.lang.StringgetAclDocumentId(java.lang.String tenant, java.lang.Long aclId)Returns the ACL Document identifier in the following format <TENANT>!<ACLID>!ACLjava.util.List<org.alfresco.solr.client.AlfrescoModel>getAlfrescoModels()Returns the Alfresco models associated with the current dictionary.java.lang.StringgetAlfrescoPropertyFromSchemaField(java.lang.String schemaField)org.alfresco.opencmis.dictionary.CMISDictionaryServicegetCMISDictionary(java.lang.String alternativeDictionary, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion)Gets the CMISDictionaryService, if an Alternative dictionary is specified it tries to get that.org.alfresco.opencmis.search.CmisFunctionEvaluationContextgetCMISFunctionEvaluationContext(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion, java.lang.String alternativeDictionary)org.apache.lucene.search.QuerygetCMISQuery(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.alfresco.util.Pair<org.alfresco.service.cmr.search.SearchParameters,java.lang.Boolean> searchParametersAndFilter, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.querymodel.Query queryModelQuery, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion, java.lang.String alternativeDictionary)static java.util.PropertiesgetCommonConfig()java.lang.StringgetDateDerivedField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)java.lang.StringgetDateDerivedSuffix(AlfrescoSolrDataModel.SpecializedFieldType type)org.alfresco.repo.dictionary.DictionaryComponentgetDictionaryService(java.lang.String alternativeDictionary)Gets a DictionaryService, if an Alternative dictionary is specified it tries to get that.java.lang.StringgetFieldForNonText(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDefinition)org.apache.lucene.search.QuerygetFTSQuery(org.alfresco.util.Pair<org.alfresco.service.cmr.search.SearchParameters,java.lang.Boolean> searchParametersAndFilter, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase)AlfrescoSolrDataModel.IndexedFieldgetIndexedFieldForSpecializedPropertyMetadata(org.alfresco.service.namespace.QName propertyQName, AlfrescoSolrDataModel.SpecializedFieldType type)AlfrescoSolrDataModel.IndexedFieldgetIndexedFieldNamesForProperty(org.alfresco.service.namespace.QName propertyQName)Get all the field names into which we must copy the source datastatic AlfrescoSolrDataModelgetInstance()org.alfresco.repo.search.impl.querymodel.impl.lucene.QueryBuilderContext<org.apache.lucene.search.Query,org.apache.lucene.search.Sort,org.apache.lucene.queryparser.classic.ParseException>getLuceneQueryBuilderContext(org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, java.lang.String alternativeDictionary, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase)Solr4QueryParsergetLuceneQueryParser(org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase)org.alfresco.repo.dictionary.NamespaceDAOgetNamespaceDAO()static java.lang.StringgetNodeDocumentId(java.lang.String tenant, java.lang.Long dbid)Returns the Solr document identifier in the following format <TENANT>!<!<DBID>org.alfresco.service.cmr.dictionary.PropertyDefinitiongetPropertyDefinition(org.alfresco.service.namespace.QName propertyQName)AlfrescoSolrDataModel.IndexedFieldgetQueryableFields(org.alfresco.service.namespace.QName propertyQName, AlfrescoSolrDataModel.SpecializedFieldType type, AlfrescoSolrDataModel.FieldUse fieldUse)java.lang.ClassLoadergetResourceClassLoader()static java.io.FilegetResourceDirectory()java.lang.StringgetStoredContentField(org.alfresco.service.namespace.QName propertyQName)java.lang.StringgetStoredContentField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)java.lang.StringgetStoredMLTextField(org.alfresco.service.namespace.QName propertyQName)java.lang.StringgetStoredMLTextField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)java.lang.StringgetStoredTextField(org.alfresco.service.namespace.QName propertyQName)java.lang.StringgetStoredTextField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)static java.lang.StringgetTenantId(java.lang.String tenant)AlfrescoSolrDataModel.SpecializedFieldTypegetTextField(java.lang.String ending)static java.lang.StringgetTransactionDocumentId(java.lang.Long txId)Returns the Transaction Document identifier in the following format TRACKER!TX!<TX_ID>booleanisDerivedDateField(java.lang.String suffix)booleanisTextField(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDefinition)java.lang.StringmapNonPropertyFields(java.lang.String queryField)java.lang.StringmapProperty(java.lang.String potentialProperty, AlfrescoSolrDataModel.FieldUse fieldUse, org.apache.solr.request.SolrQueryRequest req)java.lang.StringmapProperty(java.lang.String potentialProperty, AlfrescoSolrDataModel.FieldUse fieldUse, org.apache.solr.request.SolrQueryRequest req, int position)java.lang.StringmapStoredProperty(java.lang.String potentialProperty, org.apache.solr.request.SolrQueryRequest req)return the stored field associated to potentialProperty parameterorg.alfresco.repo.search.impl.querymodel.QueryparseCMISQueryToAlfrescoAbstractQuery(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, java.lang.String alternativeDictionary, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion)static java.lang.LongparseTransactionId(java.lang.String documentId)Extracts the transaction identifier from the input document identifier.booleanputModel(org.alfresco.repo.dictionary.M2Model model)voidremoveModel(org.alfresco.service.namespace.QName modelQName)voidsetCMDefaultUri()
-
-
-
Field Detail
-
CONTENT_S_LOCALE_PREFIX
public static final java.lang.String CONTENT_S_LOCALE_PREFIX
- See Also:
- Constant Field Values
-
log
protected static final org.slf4j.Logger log
-
DEFAULT_TENANT
public static final java.lang.String DEFAULT_TENANT
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
-
getTenantId
public static java.lang.String getTenantId(java.lang.String tenant)
-
getAclDocumentId
public static java.lang.String getAclDocumentId(java.lang.String tenant, java.lang.Long aclId)Returns the ACL Document identifier in the following format <TENANT>!<ACLID>!ACL- Parameters:
tenant- the tenant code.aclId- the acl identifer- Returns:
- the ACL Document identifier (<TENANT>!<ACLID>!ACL)
-
getAclChangeSetDocumentId
public static java.lang.String getAclChangeSetDocumentId(java.lang.Long aclChangeSetId)
Returns the ACL ChangeSet Document identifier in the following format TRACKER!CHANGESET!<ACL_CHANGESET_ID>- Parameters:
aclChangeSetId- the ACL changeset identifier.- Returns:
- the ACL ChangeSet Document identifier (TRACKER!CHANGESET!<ACL_CHANGESET_ID>)
-
parseTransactionId
public static java.lang.Long parseTransactionId(java.lang.String documentId)
Extracts the transaction identifier from the input document identifier. The "input document identifier" is the alphanumeric identifier used for Solr documents.- Parameters:
documentId- the document identifier.- Returns:
- the numeric ACL changeset identifier.
-
getNodeDocumentId
public static java.lang.String getNodeDocumentId(java.lang.String tenant, java.lang.Long dbid)Returns the Solr document identifier in the following format <TENANT>!<!<DBID>- Parameters:
tenant- the tenant code.dbid- the DB identifier.- Returns:
- the Solr document identifier in the following format <TENANT>!<!<DBID>
-
decodeNodeDocumentId
public static AlfrescoSolrDataModel.TenantDbId decodeNodeDocumentId(java.lang.String id)
Destructures a document identifier in the three compounding parts (tenant and dbid).- Parameters:
id- the document identifier.- Returns:
- a
AlfrescoSolrDataModel.TenantDbIdinstance containing the destructured identifier.
-
getTransactionDocumentId
public static java.lang.String getTransactionDocumentId(java.lang.Long txId)
Returns the Transaction Document identifier in the following format TRACKER!TX!<TX_ID>- Parameters:
txId- the transaction identifier.- Returns:
- the Transaction Document identifier in the following format TRACKER!TX!<TX_ID>
-
getAlfrescoPropertyFromSchemaField
public java.lang.String getAlfrescoPropertyFromSchemaField(java.lang.String schemaField)
-
getInstance
public static AlfrescoSolrDataModel getInstance()
-
getNamespaceDAO
public org.alfresco.repo.dictionary.NamespaceDAO getNamespaceDAO()
-
getCommonConfig
public static java.util.Properties getCommonConfig()
-
getResourceClassLoader
public java.lang.ClassLoader getResourceClassLoader()
- Returns:
- ClassLoader
-
getResourceDirectory
public static java.io.File getResourceDirectory()
-
getDictionaryService
public org.alfresco.repo.dictionary.DictionaryComponent getDictionaryService(java.lang.String alternativeDictionary)
Gets a DictionaryService, if an Alternative dictionary is specified it tries to get that. It will attempt to get the DEFAULT dictionary service if null is specified or it can't find a dictionary with the name of "alternativeDictionary"- Parameters:
alternativeDictionary- - can be null;- Returns:
- DictionaryService
-
getIndexedFieldForSpecializedPropertyMetadata
public AlfrescoSolrDataModel.IndexedField getIndexedFieldForSpecializedPropertyMetadata(org.alfresco.service.namespace.QName propertyQName, AlfrescoSolrDataModel.SpecializedFieldType type)
-
getQueryableFields
public AlfrescoSolrDataModel.IndexedField getQueryableFields(org.alfresco.service.namespace.QName propertyQName, AlfrescoSolrDataModel.SpecializedFieldType type, AlfrescoSolrDataModel.FieldUse fieldUse)
-
getStoredTextField
public java.lang.String getStoredTextField(org.alfresco.service.namespace.QName propertyQName)
-
getStoredTextField
public java.lang.String getStoredTextField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)
-
getStoredMLTextField
public java.lang.String getStoredMLTextField(org.alfresco.service.namespace.QName propertyQName)
-
getStoredMLTextField
public java.lang.String getStoredMLTextField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)
-
getStoredContentField
public java.lang.String getStoredContentField(org.alfresco.service.namespace.QName propertyQName)
-
getStoredContentField
public java.lang.String getStoredContentField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)
-
getDateDerivedField
public java.lang.String getDateDerivedField(org.alfresco.service.namespace.QName propertyQName, java.lang.String suffix)
-
getDateDerivedSuffix
public java.lang.String getDateDerivedSuffix(AlfrescoSolrDataModel.SpecializedFieldType type)
-
getIndexedFieldNamesForProperty
public AlfrescoSolrDataModel.IndexedField getIndexedFieldNamesForProperty(org.alfresco.service.namespace.QName propertyQName)
Get all the field names into which we must copy the source data- Parameters:
propertyQName- QName- Returns:
- IndexedField
-
isTextField
public boolean isTextField(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDefinition)
-
getFieldForNonText
public java.lang.String getFieldForNonText(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDefinition)
-
getPropertyDefinition
public org.alfresco.service.cmr.dictionary.PropertyDefinition getPropertyDefinition(org.alfresco.service.namespace.QName propertyQName)
-
putModel
public boolean putModel(org.alfresco.repo.dictionary.M2Model model)
-
removeModel
public void removeModel(org.alfresco.service.namespace.QName modelQName)
-
afterInitModels
public void afterInitModels()
-
parseCMISQueryToAlfrescoAbstractQuery
public org.alfresco.repo.search.impl.querymodel.Query parseCMISQueryToAlfrescoAbstractQuery(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, java.lang.String alternativeDictionary, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion)
-
getCMISFunctionEvaluationContext
public org.alfresco.opencmis.search.CmisFunctionEvaluationContext getCMISFunctionEvaluationContext(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion, java.lang.String alternativeDictionary)
-
getCMISDictionary
public org.alfresco.opencmis.dictionary.CMISDictionaryService getCMISDictionary(java.lang.String alternativeDictionary, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion)Gets the CMISDictionaryService, if an Alternative dictionary is specified it tries to get that. It will attempt to get the DEFAULT dictionary service if null is specified or it can't find a dictionary with the name of "alternativeDictionary"- Parameters:
alternativeDictionary- - can be null;- Returns:
- CMISDictionaryService
-
getAlfrescoModels
public java.util.List<org.alfresco.solr.client.AlfrescoModel> getAlfrescoModels()
Returns the Alfresco models associated with the current dictionary.- Returns:
- the Alfresco models associated with the current dictionary.
-
getCMISQuery
public org.apache.lucene.search.Query getCMISQuery(org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode mode, org.alfresco.util.Pair<org.alfresco.service.cmr.search.SearchParameters,java.lang.Boolean> searchParametersAndFilter, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.querymodel.Query queryModelQuery, org.apache.chemistry.opencmis.commons.enums.CmisVersion cmisVersion, java.lang.String alternativeDictionary) throws org.apache.lucene.queryparser.classic.ParseException- Throws:
org.apache.lucene.queryparser.classic.ParseException
-
getLuceneQueryBuilderContext
public org.alfresco.repo.search.impl.querymodel.impl.lucene.QueryBuilderContext<org.apache.lucene.search.Query,org.apache.lucene.search.Sort,org.apache.lucene.queryparser.classic.ParseException> getLuceneQueryBuilderContext(org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, java.lang.String alternativeDictionary, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase)
-
getLuceneQueryParser
public Solr4QueryParser getLuceneQueryParser(org.alfresco.service.cmr.search.SearchParameters searchParameters, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase)
-
getFTSQuery
public org.apache.lucene.search.Query getFTSQuery(org.alfresco.util.Pair<org.alfresco.service.cmr.search.SearchParameters,java.lang.Boolean> searchParametersAndFilter, org.apache.solr.request.SolrQueryRequest req, org.alfresco.repo.search.impl.parsers.FTSQueryParser.RerankPhase rerankPhase) throws org.apache.lucene.queryparser.classic.ParseException- Throws:
org.apache.lucene.queryparser.classic.ParseException
-
mapProperty
public java.lang.String mapProperty(java.lang.String potentialProperty, AlfrescoSolrDataModel.FieldUse fieldUse, org.apache.solr.request.SolrQueryRequest req)
-
mapStoredProperty
public java.lang.String mapStoredProperty(java.lang.String potentialProperty, org.apache.solr.request.SolrQueryRequest req)return the stored field associated to potentialProperty parameter
-
isDerivedDateField
public boolean isDerivedDateField(java.lang.String suffix)
-
mapProperty
public java.lang.String mapProperty(java.lang.String potentialProperty, AlfrescoSolrDataModel.FieldUse fieldUse, org.apache.solr.request.SolrQueryRequest req, int position)
-
mapNonPropertyFields
public java.lang.String mapNonPropertyFields(java.lang.String queryField)
-
getTextField
public AlfrescoSolrDataModel.SpecializedFieldType getTextField(java.lang.String ending)
- Parameters:
ending- String- Returns:
- SpecializedFieldType
-
setCMDefaultUri
public void setCMDefaultUri()
-
destructuredDateTimePartFieldNamePrefix
public java.lang.String destructuredDateTimePartFieldNamePrefix(java.lang.String sourceFieldName)
Returns the prefix used for denoting a field which is meant to represent a constituent part of a date or datetime (e.g. year, month, second, minute).- Parameters:
sourceFieldName- the date/datetime source field name.- Returns:
- the prefix that can be used for denoting a date or datetime part
-
-