@ThreadSafe @Immutable public abstract class LuceneIndex extends Object implements ProvidedIndex<Object>
Filter.Results| Modifier and Type | Field and Description |
|---|---|
protected LuceneConfig |
config |
protected ExecutionContext |
context |
protected Logger |
logger |
protected String |
name |
protected Map<String,PropertyType> |
propertyTypesByName |
protected Searcher |
searcher |
protected StringFactory |
stringFactory |
protected org.apache.lucene.index.IndexWriter |
writer |
| Modifier | Constructor and Description |
|---|---|
protected |
LuceneIndex(String name,
String workspaceName,
LuceneConfig config,
Map<String,PropertyType> propertyTypesByName,
ExecutionContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String nodeKey,
String propertyName,
Object value)
Adds a single value to this index for the given node.
|
protected void |
addBinaryField(String propertyName,
Object value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addBooleanField(String propertyName,
Boolean value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addDateField(String propertyName,
DateTime value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addDecimalField(String propertyName,
BigDecimal value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addDoubleField(String propertyName,
Double value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addLongField(String propertyName,
Long value,
List<org.apache.lucene.document.Field> fields) |
protected void |
addProperty(String nodeKey,
org.apache.lucene.document.Document document,
String property,
Object... values) |
protected void |
addStringField(String propertyName,
String value,
List<org.apache.lucene.document.Field> fields) |
void |
clearAllData()
Remove all of the index entries from the index.
|
void |
commit()
Commits any potential changes made by the add/remove/update operations to this index.
|
long |
estimateCardinality(List<Constraint> andedConstraints,
Map<String,Object> variables)
Compute the cost applying the given constraints joined together conceptually using AND.
|
long |
estimateTotalCount()
Get the estimated number of entries within this index.
|
Filter.Results |
filter(IndexConstraints constraints)
Return a
Filter.Results instance from which ModeShape can obtain the nodes that satisfy the supplied constraints. |
String |
getName()
Get the name of the index.
|
protected void |
postCommit() |
protected void |
preCommit(Map<String,String> commitData) |
protected abstract LuceneQueryFactory |
queryFactory(Map<String,Object> variables) |
void |
remove(String nodeKey)
Removes the given node from the index.
|
protected abstract void |
remove(String nodeKey,
String propertyName) |
void |
remove(String nodeKey,
String propertyName,
Object value)
Removes a value for the given node from the index.
|
void |
remove(String nodeKey,
String propertyName,
Object[] values)
Removes multiple values from the index for the given node.
|
boolean |
requiresReindexing()
Return whether this index is newly created and requires reindexing, or false if the index already exists.
|
void |
shutdown(boolean destroyed)
Shut down this index and release all runtime resources.
|
protected List<org.apache.lucene.document.Field> |
valuesToFields(String propertyName,
Object... values) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddprotected final Logger logger
protected final String name
protected final ExecutionContext context
protected final org.apache.lucene.index.IndexWriter writer
protected final Map<String,PropertyType> propertyTypesByName
protected final LuceneConfig config
protected final StringFactory stringFactory
protected final Searcher searcher
protected LuceneIndex(String name, String workspaceName, LuceneConfig config, Map<String,PropertyType> propertyTypesByName, ExecutionContext context)
public void add(String nodeKey, String propertyName, Object value)
ProvidedIndexadd in interface ProvidedIndex<Object>nodeKey - a NodeKey instance, never nullpropertyName - the name for which the value is removed, never null but certain providers
may ignore the value. Most of the times this is the real JCR property name, but for some index types (e.g. node types
index) this may be something else (e.g. the name of the index)value - an Object instance, never nullpublic void remove(String nodeKey)
ProvidedIndexremove in interface ProvidedIndex<Object>nodeKey - a NodeKey instance, never nullpublic void remove(String nodeKey, String propertyName, Object value)
ProvidedIndexremove in interface ProvidedIndex<Object>nodeKey - a NodeKey instance, never nullpropertyName - the name for which the value is removed, never null but certain providers
may ignore the value. Most of the times this is the real JCR property name, but for some index types (e.g. node types
index) this may be something else (e.g. the name of the index)value - the value to remove from the index for this node, never nullpublic void remove(String nodeKey, String propertyName, Object[] values)
ProvidedIndexremove in interface ProvidedIndex<Object>nodeKey - a NodeKey instance, never nullpropertyName - the name for which the value is removed, never null but certain providers
may ignore the value. Most of the times this is the real JCR property name, but for some index types (e.g. node types
index) this may be something else (e.g. the name of the index)values - the values to remove, never null or emptypublic String getName()
ProvidedIndexgetName in interface ProvidedIndex<Object>public long estimateCardinality(List<Constraint> andedConstraints, Map<String,Object> variables)
CostableestimateCardinality in interface CostableandedConstraints - the constraints; never nullvariables - the bound variables for the query that is being costed; never nullpublic long estimateTotalCount()
CostableestimateTotalCount in interface Costablepublic Filter.Results filter(IndexConstraints constraints)
FilterFilter.Results instance from which ModeShape can obtain the nodes that satisfy the supplied constraints. This
method should return quickly, since no work (or at least very little work) should be done. All of the work should be
performed when the Filter.Results.getNextBatch(ResultWriter, int) method is called on the results.public boolean requiresReindexing()
ReindexablerequiresReindexing in interface Reindexablepublic void commit()
ProvidedIndexcommit in interface ProvidedIndex<Object>protected void postCommit()
public void shutdown(boolean destroyed)
Lifecycledestroyed is true, then this index has been
removed from the repository and will not be reused; thus all persistent resources should also be released. If
destroyed is false, then this repository is merely shutting down and the index's persistent resources
should be kept so that they are available when the repository is restarted.shutdown in interface Lifecycledestroyed - true if this index is being permanently removed from the repository and all runtime and persistent
resources can/should be released and cleaned up, or false if the repository is being shutdown and this index will be
needed the next time the repository is startedpublic void clearAllData()
ReindexableclearAllData in interface Reindexableprotected void addProperty(String nodeKey, org.apache.lucene.document.Document document, String property, Object... values)
protected abstract LuceneQueryFactory queryFactory(Map<String,Object> variables)
protected List<org.apache.lucene.document.Field> valuesToFields(String propertyName, Object... values)
protected void addStringField(String propertyName, String value, List<org.apache.lucene.document.Field> fields)
protected void addBooleanField(String propertyName, Boolean value, List<org.apache.lucene.document.Field> fields)
protected void addDateField(String propertyName, DateTime value, List<org.apache.lucene.document.Field> fields)
protected void addBinaryField(String propertyName, Object value, List<org.apache.lucene.document.Field> fields)
protected void addDecimalField(String propertyName, BigDecimal value, List<org.apache.lucene.document.Field> fields)
protected void addDoubleField(String propertyName, Double value, List<org.apache.lucene.document.Field> fields)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.