public class LuceneIndex extends GeneratedLuceneIndex
LucenesearchManager,
IndexConfiguration,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
LuceneIndex.CombinedFilter |
protected static class |
LuceneIndex.IndexProvider
IndexProvider methods #lock(File) , #unlock(File) are guarded by a
ReentrantReadWriteLock.writeLock() for
every distinguish directory name. |
protected class |
LuceneIndex.MyQueryParser |
static class |
LuceneIndex.ResultBitSetCacheUnit
Special cache unit caching facet value BitSets for a given index.
|
GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationExceptionCODE, DEFAULT_INITIAL_ATTRIBUTES, INDEXCONFIGURATIONS, LANGUAGECONFIGURATIONS, PENDINGUPDATESCOUNT, POSTQUERYFILTERCLASSNAME, REBUILDENDTIMESTAMP, REBUILDSTARTTIMESTAMP, TESTLOC, UPTODATELANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
LuceneIndex() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearAllScheduledUpdates() |
Set<Facet> |
cloneFacets(Set<Facet> facets) |
protected IndexWriter |
configureIndexWriter(IndexWriter writer,
int indexConfigurationSize,
boolean rebuild) |
protected Map<Facet.FacetValue,Query> |
createCountQueries(SessionContext ctx,
Facet facet)
This method provides a single query for each facet value which is being used for calculating the actual hit
count of this value within the search result.
|
protected Query |
createCountQuery(SessionContext ctx,
Facet.FacetValue value)
Creates the query for a single facet value.
|
IndexConfiguration |
createIndexConfiguration(ComposedType indexedType)
Create a new IndexConfiguration, without initial languages or indexed attributes.
|
IndexConfiguration |
createIndexConfiguration(ComposedType indexedType,
Collection<AttributeDescriptor> indexedAttributes)
Create a new IndexConfiguration.
|
protected Item |
createItem(SessionContext ctx,
ComposedType type,
Item.ItemAttributeMap allAttributes)
Has to be implemented for each concrete subtype of item.
|
LanguageConfiguration |
createLanguageConfiguration(Language lang) |
LanguageConfiguration |
createLanguageConfiguration(Language lang,
String analyzerDefinition) |
protected Filter |
createMandatoryValuesFilter(SessionContext ctx,
Set<Facet> facets) |
protected Query |
createMandatoryValuesQuery(SessionContext ctx,
Facet facet)
Optionally create a query to limit the actual search result to a set of facet values.
|
protected LuceneSearchResult |
createResult(SessionContext ctx,
TopDocs hits,
Set<Facet> facets,
int requestedStart,
int requestedCount,
IndexSearcher searcher) |
protected String |
createTemporaryDirectoryName(Language language) |
protected String |
createTenantAwarePrefix(String oldPrefix)
wraps old index directory prefix name with current tenant id if only current tenant is not master tenant
|
protected Map<Language,IndexWriter> |
createWriterMap(boolean rebuild,
int indexConfigurationSize) |
protected void |
deleteRecursively(File file) |
protected String |
fileToString(File file) |
protected Analyzer |
getAnalyzer(SessionContext ctx) |
protected DocIdSet |
getFacetValueBitsCached(SessionContext ctx,
int clusterNode,
AtomicReader atomicReader,
Facet.FacetValue facetValue)
Fetches the bit set of all matching documents for a given facet value.
|
protected Map<String,Boolean> |
getFieldMappings() |
Collection<IndexConfiguration> |
getIndexConfigurations()
Generated method - Getter of the
LuceneIndex.indexConfigurations attribute. |
Collection<IndexConfiguration> |
getIndexConfigurations(SessionContext ctx)
Gets all IndexConfigurations in this index.
|
Collection<IndexConfiguration> |
getIndexConfigurationsByIndexedType(ComposedType indexedType)
Gets the IndexConfigurations in this index with the given indexedType.
|
Map<IndexConfiguration,Set<Item>> |
getIndexConfigurationsUpdateMap(Collection<Item> items) |
protected File |
getIndexDirectory(String dirName) |
protected File |
getIndexDirectory(String dirName,
boolean create) |
protected static LuceneIndex.IndexProvider |
getIndexProvider() |
LanguageConfiguration |
getLanguageConfiguration(Language language) |
Collection<LanguageConfiguration> |
getLanguageConfigurations()
Generated method - Getter of the
LuceneIndex.languageConfigurations attribute. |
Collection<LanguageConfiguration> |
getLanguageConfigurations(SessionContext ctx)
Generated method - Getter of the
LuceneIndex.languageConfigurations attribute. |
Collection<Language> |
getLanguages() |
Integer |
getPendingUpdatesCount(SessionContext ctx)
Generated method - Getter of the
LuceneIndex.pendingUpdatesCount attribute. |
protected PostQueryFilter |
getPostQueryFilter() |
protected String |
getProductiveDirectoryName(Language language)
The name is constructed as
prod- code . |
protected Map<ComposedType,Set<IndexConfiguration>> |
getType2IndexConfigMap() |
boolean |
hasAttributes()
Checks if the index has at least one configuration containing at least one attribute.
|
protected void |
invalidateQueryCaches() |
Boolean |
isUpToDate(SessionContext ctx)
Generated method - Getter of the
LuceneIndex.upToDate attribute. |
protected void |
notifyLanguageConfigurationRemoving(LanguageConfiguration cfg) |
Query |
parseQuery(SessionContext ctx,
String pattern)
Parses the given pattern and returns the corresponding lucene
Query. |
protected void |
processFacets(SessionContext ctx,
AtomicReader atomicReader,
Query baseQuery,
Filter filter,
Set<Facet> facets) |
protected DocIdSet |
queryFacetBits(SessionContext ctx,
AtomicReader atomicReader,
Facet.FacetValue facetValue) |
Set<Facet> |
queryFacets(SessionContext ctx,
Query query,
Filter filter,
Set<Facet> _facets)
Shortcut for just getting facet information rather than fetching the whole result.
|
void |
rebuildIndex()
Completely rebuilds the index.
|
void |
remove(SessionContext ctx)
remove IndexConfigurations
|
void |
removeItemFromIndex(Collection items) |
void |
removeItemFromIndex(Item item)
Removes a an given Item from index configuration.
|
protected void |
renameOrFail(File fileFrom,
File fileTo) |
LuceneSearchResult |
searchItems(SessionContext ctx,
Query query,
Filter filter,
Sort sort,
int requestedStart,
int requestedCount)
Search in this lucene index; first define your own QueryParser where you interprete your own pattern, the result
from the QueryParser (a query) is needed for this method.
|
LuceneSearchResult |
searchItems(SessionContext ctx,
Query query,
Filter filter,
Sort sort,
Set<Facet> _facets,
int requestedStart,
int requestedCount) |
LuceneSearchResult |
searchItems(SessionContext ctx,
String pattern,
int requestedStart,
int requestedCount)
Search for the given pattern in this LuceneIndex, with no constraint on groups.
|
LuceneSearchResult |
searchItems(SessionContext ctx,
String pattern,
List groups,
Filter filter,
Sort sort,
int requestedStart,
int requestedCount) |
LuceneSearchResult |
searchItems(SessionContext ctx,
String pattern,
List groups,
Filter filter,
Sort sort,
Set<Facet> facets,
int requestedStart,
int requestedCount) |
LuceneSearchResult |
searchItems(SessionContext ctx,
String pattern,
List groups,
int requestedStart,
int requestedCount)
Search in this LuceneIndex, default implementation of a search with a given pattern; the query is generated in
this method and then the methods searchItems(ctx, query, int, int) is called.
|
LuceneSearchResult |
searchItems(SessionContext ctx,
String pattern,
List groups,
String orderBy,
boolean ascending,
int requestedStart,
int requestedCount) |
void |
setIndexConfigurations(SessionContext ctx,
Collection<IndexConfiguration> indexConfigurations)
Set the IndexConfigurations of this index.
|
void |
setLanguageConfigurations(SessionContext ctx,
Collection<LanguageConfiguration> coll)
Generated method - Setter of the
LuceneIndex.languageConfigurations attribute. |
protected void |
setProductive(Language language,
File tempDir)
Sets a temporary index directory as a replace for current productive for given language.
|
protected void |
setRebuildEndTimestamp(Date timestamp) |
protected void |
setRebuildStartTimestamp(Date timestamp) |
void |
updateIndexForItem(Collection<Item> items)
Update the data for the given items in this index.
|
void |
updateIndexForItem(Item item)
Update the data for the given item in the index.
|
void |
updateIndexForItem(Map<IndexConfiguration,Set<Item>> cfg2ItemsMap) |
getAllTestLoc, getAllTestLoc, getCode, getCode, getDefaultAttributeModes, getPendingUpdatesCount, getPendingUpdatesCountAsPrimitive, getPendingUpdatesCountAsPrimitive, getPostQueryFilterClassName, getPostQueryFilterClassName, getRebuildEndTimestamp, getRebuildEndTimestamp, getRebuildStartTimestamp, getRebuildStartTimestamp, getTestLoc, getTestLoc, isUpToDate, isUpToDateAsPrimitive, isUpToDateAsPrimitive, setAllTestLoc, setAllTestLoc, setCode, setCode, setIndexConfigurations, setLanguageConfigurations, setPostQueryFilterClassName, setPostQueryFilterClassName, setTestLoc, setTestLocgetInitialProperties, getNonInitialAttributesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, readResolve, refreshRemote, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setTransientObject, setUseTA, toString, useTA, writeReplacegetImplementation, setTenantprotected static final LuceneIndex.IndexProvider getIndexProvider()
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
ItemComposedType.newInstance(Map).
In case this method uses any of the attribute values during creation it is required to override
Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
Sn example:
public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
// here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
super.getNonInitialAttributes( ctx, allAttributes );
// remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
createItem in class GenericItemctx - the current session context which this item is created withintype - the actual item type ( since subtypes may not provide a own jalo class this may be different from the
type which this method was implemented for )JaloBusinessException - indicates an error during creation - any changes will be rollbackedpublic void remove(SessionContext ctx) throws ConsistencyCheckException
remove in class Itemctx - A SessionContext objectConsistencyCheckException - if this item could not be removed for some reasonpublic LanguageConfiguration createLanguageConfiguration(Language lang)
public LanguageConfiguration createLanguageConfiguration(Language lang, String analyzerDefinition)
public IndexConfiguration createIndexConfiguration(ComposedType indexedType)
public IndexConfiguration createIndexConfiguration(ComposedType indexedType, Collection<AttributeDescriptor> indexedAttributes)
indexedType - the indexed typeindexedAttributes - a collection of AttributeDescriptorspublic void setIndexConfigurations(SessionContext ctx, Collection<IndexConfiguration> indexConfigurations)
setIndexConfigurations in class GeneratedLuceneIndexindexConfigurations - the indexConfigurations - The IndexConfiguration objects belonging to this
LuceneIndex.public Collection<IndexConfiguration> getIndexConfigurations()
GeneratedLuceneIndexLuceneIndex.indexConfigurations attribute.getIndexConfigurations in class GeneratedLuceneIndexpublic Collection<IndexConfiguration> getIndexConfigurations(SessionContext ctx)
getIndexConfigurations in class GeneratedLuceneIndexIndexConfigurationspublic Collection<IndexConfiguration> getIndexConfigurationsByIndexedType(ComposedType indexedType)
IndexConfigurationspublic Boolean isUpToDate(SessionContext ctx)
GeneratedLuceneIndexLuceneIndex.upToDate attribute.isUpToDate in class GeneratedLuceneIndexprotected void setRebuildStartTimestamp(Date timestamp)
protected void setRebuildEndTimestamp(Date timestamp)
public void rebuildIndex()
throws IndexAccessException
The attributes GeneratedLuceneIndex.getRebuildStartTimestamp()and
GeneratedLuceneIndex.getRebuildEndTimestamp()are updated before and after rebuilding the index,
respectively.
IndexAccessExceptionprotected void clearAllScheduledUpdates()
protected void setProductive(Language language, File tempDir) throws IOException
IOExceptionprotected void notifyLanguageConfigurationRemoving(LanguageConfiguration cfg)
protected Map<Language,IndexWriter> createWriterMap(boolean rebuild, int indexConfigurationSize)
protected IndexWriter configureIndexWriter(IndexWriter writer,
int indexConfigurationSize,
boolean rebuild)
public Map<IndexConfiguration,Set<Item>> getIndexConfigurationsUpdateMap(Collection<Item> items)
protected Map<ComposedType,Set<IndexConfiguration>> getType2IndexConfigMap()
public void removeItemFromIndex(Item item)
public void removeItemFromIndex(Collection items)
removeItemFromIndex(Item)public void updateIndexForItem(Item item)
The attributes GeneratedLuceneIndex.getRebuildStartTimestamp()and
GeneratedLuceneIndex.getRebuildEndTimestamp()are updated before and after rebuilding the index,
respectively.
public void updateIndexForItem(Collection<Item> items)
The attributes GeneratedLuceneIndex.getRebuildStartTimestamp() and
GeneratedLuceneIndex.getRebuildEndTimestamp()are not updated before and after rebuilding the index,
respectively.
public void updateIndexForItem(Map<IndexConfiguration,Set<Item>> cfg2ItemsMap)
protected String createTenantAwarePrefix(String oldPrefix)
protected String getProductiveDirectoryName(Language language)
prod- code .protected void renameOrFail(File fileFrom, File fileTo) throws IOException
IOExceptionprotected void deleteRecursively(File file)
protected PostQueryFilter getPostQueryFilter()
public LuceneSearchResult searchItems(SessionContext ctx, String pattern, int requestedStart, int requestedCount)
ctx - defines the search languagepattern - see searchItems(SessionContext, String, List, int, int)requestedCount - maximum number of found items to be returned; -1 for no limitpublic LuceneSearchResult searchItems(SessionContext ctx, String pattern, List groups, int requestedStart, int requestedCount)
ctx - defines the search languagepattern - search pattern, will be parsed by the lucene QueryParsergroups - may be null, for no constraint on groups; default value is the itemtype valuerequestedCount - maximum number of found items to be returned; -1 for no limitpublic LuceneSearchResult searchItems(SessionContext ctx, String pattern, List groups, String orderBy, boolean ascending, int requestedStart, int requestedCount)
public LuceneSearchResult searchItems(SessionContext ctx, String pattern, List groups, Filter filter, Sort sort, int requestedStart, int requestedCount)
public LuceneSearchResult searchItems(SessionContext ctx, String pattern, List groups, Filter filter, Sort sort, Set<Facet> facets, int requestedStart, int requestedCount)
public Query parseQuery(SessionContext ctx, String pattern) throws org.apache.lucene.queryparser.classic.ParseException
Query. The default implementation sets
the default field according to the Language of the specified SessionContext and uses the
StandardAnalyzer from lucene. If the search pattern is null or "", a "*" will be as default pattern
assumedctx - the SessionContext, which will be used for retrieving the search languagepattern - the search patternQueryParseException - if an ParseException occurs during parsingorg.apache.lucene.queryparser.classic.ParseExceptionprotected Analyzer getAnalyzer(SessionContext ctx)
public LuceneSearchResult searchItems(SessionContext ctx, Query query, Filter filter, Sort sort, int requestedStart, int requestedCount) throws org.apache.lucene.queryparser.classic.ParseException
ctx - sessioncontext, defines the search languagequery - result of a QueryParserrequestedStart - startnumberrequestedCount - maximum number of found items to be returned; -1 for no limitsort - encapsulates sort criteria for returned hitsfilter - base class providing a mechanism to restrict searches to a subset of an indexLuceneSearchResultorg.apache.lucene.queryparser.classic.ParseExceptionpublic Set<Facet> queryFacets(SessionContext ctx, Query query, Filter filter, Set<Facet> _facets) throws org.apache.lucene.queryparser.classic.ParseException
ctx - query - filter - _facets - org.apache.lucene.queryparser.classic.ParseExceptionpublic LuceneSearchResult searchItems(SessionContext ctx, Query query, Filter filter, Sort sort, Set<Facet> _facets, int requestedStart, int requestedCount) throws org.apache.lucene.queryparser.classic.ParseException
protected Filter createMandatoryValuesFilter(SessionContext ctx, Set<Facet> facets) throws ParseException
ParseExceptionprotected Query createMandatoryValuesQuery(SessionContext ctx, Facet facet)
Occur object to contribute to this query. Otherwise it is ignored.ParseExceptionprotected Map<Facet.FacetValue,Query> createCountQueries(SessionContext ctx, Facet facet)
ParseExceptionprotected Query createCountQuery(SessionContext ctx, Facet.FacetValue value)
createMandatoryValuesQuery(SessionContext, Facet) and createCountQueries(SessionContext, Facet).ParseExceptionprotected void invalidateQueryCaches()
protected DocIdSet queryFacetBits(SessionContext ctx, AtomicReader atomicReader, Facet.FacetValue facetValue) throws IOException
IOExceptionprotected DocIdSet getFacetValueBitsCached(SessionContext ctx, int clusterNode, AtomicReader atomicReader, Facet.FacetValue facetValue)
lucenesearch.facets.cache parameter is set to true inside the platform
project.properties or local.properties.ctx - the current session context - required to read session language fromclusterNode - the current cluster node because results are cached per code onlyatomicReader - the index reader to run the query upon in case no cached result is availablefacetValue - the facet valueprotected void processFacets(SessionContext ctx, AtomicReader atomicReader, Query baseQuery, Filter filter, Set<Facet> facets) throws IOException
IOExceptionprotected LuceneSearchResult createResult(SessionContext ctx, TopDocs hits, Set<Facet> facets, int requestedStart, int requestedCount, IndexSearcher searcher) throws IOException
IOExceptionpublic Collection<Language> getLanguages()
public Collection<LanguageConfiguration> getLanguageConfigurations()
GeneratedLuceneIndexLuceneIndex.languageConfigurations attribute.getLanguageConfigurations in class GeneratedLuceneIndexpublic Collection<LanguageConfiguration> getLanguageConfigurations(SessionContext ctx)
GeneratedLuceneIndexLuceneIndex.languageConfigurations attribute.getLanguageConfigurations in class GeneratedLuceneIndexpublic LanguageConfiguration getLanguageConfiguration(Language language)
public void setLanguageConfigurations(SessionContext ctx, Collection<LanguageConfiguration> coll)
GeneratedLuceneIndexLuceneIndex.languageConfigurations attribute.setLanguageConfigurations in class GeneratedLuceneIndexcoll - the languageConfigurations - The LanguageConfiguration objects belonging to
this LuceneIndex.public Integer getPendingUpdatesCount(SessionContext ctx)
GeneratedLuceneIndexLuceneIndex.pendingUpdatesCount attribute.getPendingUpdatesCount in class GeneratedLuceneIndexpublic boolean hasAttributes()
Copyright © 2017 SAP SE. All Rights Reserved.