public class LuceneIndex extends java.lang.Object implements QueryIndex.AdvanceFulltextQueryIndex
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
propertyexcludePropertyNames
propertyreindex
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.AdvanceFulltextQueryIndex, QueryIndex.FulltextQueryIndex, QueryIndex.IndexPlan, QueryIndex.NativeQueryIndex, QueryIndex.NodeAggregator, QueryIndex.OrderEntry
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NATIVE_QUERY_FUNCTION |
Constructor and Description |
---|
LuceneIndex(IndexTracker tracker,
QueryIndex.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.
|
java.lang.String |
getIndexName()
Get the generic index name (normally the index type).
|
double |
getMinimumCost()
Returns the minimum cost which
QueryIndex.getCost(Filter, NodeState) would return in the best possible case. |
QueryIndex.NodeAggregator |
getNodeAggregator()
Returns the NodeAggregator responsible for providing the aggregation
settings or null if aggregation is not available/desired.
|
java.lang.String |
getPlan(Filter filter,
NodeState root)
Get the query plan for the given filter.
|
java.lang.String |
getPlanDescription(QueryIndex.IndexPlan plan,
NodeState root)
Get the query plan description (for logging purposes).
|
java.util.List<QueryIndex.IndexPlan> |
getPlans(Filter filter,
java.util.List<QueryIndex.OrderEntry> sortOrder,
NodeState rootState)
Return the possible index plans for the given filter and sort order.
|
Cursor |
query(Filter filter,
NodeState root)
Query the index.
|
Cursor |
query(QueryIndex.IndexPlan plan,
NodeState rootState)
Start a query.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIndexName
public static final java.lang.String NATIVE_QUERY_FUNCTION
public LuceneIndex(IndexTracker tracker, QueryIndex.NodeAggregator aggregator)
public double getMinimumCost()
QueryIndex
QueryIndex.getCost(Filter, NodeState)
would return in the best possible case.
The implementation should return a static/cached value because it is called very often.
getMinimumCost
in interface QueryIndex
public java.lang.String getIndexName()
QueryIndex
getIndexName
in interface QueryIndex
public java.util.List<QueryIndex.IndexPlan> getPlans(Filter filter, java.util.List<QueryIndex.OrderEntry> sortOrder, NodeState rootState)
QueryIndex.AdvancedQueryIndex
getPlans
in interface QueryIndex.AdvancedQueryIndex
filter
- the filtersortOrder
- the sort order or null if no sorting is requiredrootState
- root state of the current repository snapshotpublic 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 java.lang.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 java.lang.String getPlanDescription(QueryIndex.IndexPlan plan, NodeState root)
QueryIndex.AdvancedQueryIndex
The index plan is one of the plans that the index returned in the getPlans call.
getPlanDescription
in interface QueryIndex.AdvancedQueryIndex
plan
- the index planroot
- 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 Cursor query(QueryIndex.IndexPlan plan, NodeState rootState)
QueryIndex.AdvancedQueryIndex
The index plan is one of the plans that the index returned in the getPlans call.
query
in interface QueryIndex.AdvancedQueryIndex
plan
- the index plan to userootState
- root state of the current repository snapshotpublic QueryIndex.NodeAggregator getNodeAggregator()
QueryIndex.FulltextQueryIndex
getNodeAggregator
in interface QueryIndex.FulltextQueryIndex
Copyright © 2010 - 2020 Adobe. All Rights Reserved