public class LuceneIndex extends Object implements QueryIndex.FulltextQueryIndex
To define a lucene index on a subtree you have to add an
oak:index
node.
Under it follows the index definition node that:
oak:QueryIndexDefinition
type
property set to lucene
async
property set to async
Optionally you can add
includePropertyTypes property
excludePropertyNames property
reindex flag which when set to true, triggers a full content re-index.
{
NodeBuilder index = root.child("oak:index");
index.child("lucene")
.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME)
.setProperty("type", "lucene")
.setProperty("async", "async")
.setProperty("reindex", "true");
}
QueryIndex
QueryIndex.AdvancedQueryIndex, QueryIndex.FulltextQueryIndex, QueryIndex.IndexPlan, QueryIndex.OrderEntry
Modifier and Type | Field and Description |
---|---|
static String |
NATIVE_QUERY_FUNCTION |
Constructor and Description |
---|
LuceneIndex(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker tracker,
Analyzer analyzer,
NodeAggregator aggregator) |
Modifier and Type | Method and Description |
---|---|
double |
getCost(Filter filter,
NodeState root)
Estimate the worst-case cost to query with the given filter.
|
String |
getIndexName()
Get the unique index name.
|
NodeAggregator |
getNodeAggregator()
Returns the NodeAggregator responsible for providing the aggregation
settings or null if aggregation is not available/desired.
|
String |
getPlan(Filter filter,
NodeState root)
Get the query plan for the given filter.
|
Cursor |
query(Filter filter,
NodeState root)
Query the index.
|
public static final String NATIVE_QUERY_FUNCTION
public LuceneIndex(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker tracker, Analyzer analyzer, NodeAggregator aggregator)
public String getIndexName()
QueryIndex
getIndexName
in interface QueryIndex
public double getCost(Filter filter, NodeState root)
QueryIndex
The returned value is supposed to be an estimate and doesn't have to be very accurate. Please note this method is called on each index whenever a query is run, so the method should be reasonably fast (not read any data itself, or at least not read too much data).
If an index implementation can not query the data, it has to return
Double.MAX_VALUE
.
getCost
in interface QueryIndex
filter
- the filterroot
- root state of the current repository snapshotpublic String getPlan(Filter filter, NodeState root)
QueryIndex
EXPLAIN SELECT
query, or for logging purposes. The
result should be human readable.getPlan
in interface QueryIndex
filter
- the filterroot
- root state of the current repository snapshotpublic Cursor query(Filter filter, NodeState root)
QueryIndex
An implementation should only filter the result if it can do so easily and efficiently; the query engine will verify the data again (in memory) and check for access rights.
The method is only called if this index is used for the given query and
selector, which is only the case if the given index implementation
returned the lowest cost for the given filter. If the implementation
returned Double.MAX_VALUE
in the getCost method for the given
filter, then this method is not called. If it is still called, then it is
supposed to throw an exception (as it would be an internal error of the
query engine).
query
in interface QueryIndex
filter
- the filterroot
- root state of the current repository snapshotpublic NodeAggregator getNodeAggregator()
QueryIndex.FulltextQueryIndex
getNodeAggregator
in interface QueryIndex.FulltextQueryIndex
"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"