public class GraphIndexer extends ResourceFinder
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAXHITS
Default value for
maxhits . |
Constructor and Description |
---|
GraphIndexer(TripleCollection definitionGraph,
TripleCollection baseGraph)
Creates a new in-memory index with default
maxHits . |
GraphIndexer(TripleCollection definitionGraph,
TripleCollection baseGraph,
org.apache.lucene.store.Directory indexDirectory,
boolean createNewIndex)
Creates a new index with default
maxHits . |
GraphIndexer(TripleCollection definitionGraph,
TripleCollection baseGraph,
org.apache.lucene.store.Directory indexDirectory,
boolean createNewIndex,
int maxHits)
Creates a new index.
|
Modifier and Type | Method and Description |
---|---|
void |
closeLuceneIndex()
Releases resources held by GraphIndexer.
|
void |
finalize() |
List<NonLiteral> |
findResources(List<? extends Condition> conditions,
SortSpecification sortSpecification,
FacetCollector... facetCollectors)
Find resources using conditions and collect facets and a sort order.
|
List<NonLiteral> |
findResources(List<? extends Condition> conditions,
SortSpecification sortSpecification,
List<FacetCollector> facetCollectors,
int from,
int to)
Find resources using conditions and collect facets and specify a sort
order.
|
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Returns the Analyzer used by this GraphIndexer instance.
|
TripleCollection |
getBaseGraph()
Returns the graph that this GraphIndexer builds an index on.
|
TripleCollection |
getDefinitionGraph()
Returns the graph where the index definitions are stored.
|
int |
getMaxHits()
How many results a search on the index returns maximally.
|
protected void |
indexResource(Resource resource,
org.apache.lucene.index.IndexWriter writer)
Index a resource.
|
void |
optimizeIndex()
optimize the index
|
protected void |
processDefinitions()
Read the index definitions and initialize the GraphIndexer with them.
|
void |
reCreateIndex()
recreates the index
|
protected void |
scheduleForReindex(Resource resource)
Schedule an update or creation of an index for a resource.
|
void |
scheduleIndexOptimizations(long delay,
long period)
Schedule optimizations for repeated executions.
|
void |
setMaxHits(int maxHits)
Set how many results a search on the index returns maximally.
|
void |
terminateIndexOptimizationSchedule()
Cancel scheduled optimizations.
|
findResources, findResources, findResources, findResources, findResources, findResources, findResources, findResources, findResources, findResources
public static final int DEFAULT_MAXHITS
maxhits
.public GraphIndexer(TripleCollection definitionGraph, TripleCollection baseGraph, org.apache.lucene.store.Directory indexDirectory, boolean createNewIndex, int maxHits)
GraphIndexer
looks for specifications of what properties on
what resources to index in the definitionGraph
.
The baseGraph
specifies the graph on which the index is built.
Notes:
This is an expensive operation and it is advisable to call
closeLuceneIndex()
when this instance is no longer needed.
The GraphIndexer must have write-access to the index directory specified.
definitionGraph
- where index definitions are storedbaseGraph
- where the resources to index are storedindexDirectory
- The directory where the index is stored.createNewIndex
- Whether to create a new index or reuse an existing
one. The constructor does not check if there is a valid exiting index.
The user is responsible for setting this value correctly.maxHits
- How many results the indexer returns. All entries in the
index are searched, but only @code{maxHits} resources are resolved and
returned in the result.IndexDefinitionManager
public GraphIndexer(TripleCollection definitionGraph, TripleCollection baseGraph, org.apache.lucene.store.Directory indexDirectory, boolean createNewIndex)
maxHits
.
The GraphIndexer
looks for specifications of what properties on
what resources to index in the definitionGraph
.
The baseGraph
specifies the graph on which the index is built.
Notes:
This is an expensive operation and it is advisable to call
closeLuceneIndex()
when this instance is no longer needed.
The GraphIndexer must have write-access to the index directory specified.
definitionGraph
- where index definitions are storedbaseGraph
- where the resources to index are storedindexDirectory
- The directory where the index is stored.createNewIndex
- Whether to create a new index or reuse an existing
one. The constructor does not check if there is a valid exiting index.
The user is responsible for setting this value correctly.public GraphIndexer(TripleCollection definitionGraph, TripleCollection baseGraph)
maxHits
.
The GraphIndexer
looks for specifications of what properties on
what resources to index in the definitionGraph
.
The baseGraph
specifies the graph on which the index is built.
Notes:
This is an expensive operation and it is advisable to call
closeLuceneIndex()
when this instance is no longer needed.
The GraphIndexer must have write-access to the index directory specified.
definitionGraph
- where index definitions are storedbaseGraph
- where the resources to index are storedpublic void closeLuceneIndex()
public org.apache.lucene.analysis.Analyzer getAnalyzer()
public TripleCollection getBaseGraph()
public TripleCollection getDefinitionGraph()
public int getMaxHits()
public void setMaxHits(int maxHits)
maxHits
- the maximum number of results.public void optimizeIndex()
ResourceFinder
optimizeIndex
in class ResourceFinder
public void scheduleIndexOptimizations(long delay, long period)
delay
- The delay before the first execution in milliseconds.period
- Time between successive executions (execution rate) in
milliseconds.public void terminateIndexOptimizationSchedule()
public void reCreateIndex()
ResourceFinder
reCreateIndex
in class ResourceFinder
public List<NonLiteral> findResources(List<? extends Condition> conditions, SortSpecification sortSpecification, FacetCollector... facetCollectors) throws org.apache.lucene.queryparser.classic.ParseException
ResourceFinder
findResources
in class ResourceFinder
conditions
- a list of conditions to construct a query from.sortSpecification
- specifies the sort order.facetCollectors
- facet collectors to apply to the query result.org.apache.lucene.queryparser.classic.ParseException
- when the resulting query is illegal.public List<NonLiteral> findResources(List<? extends Condition> conditions, SortSpecification sortSpecification, List<FacetCollector> facetCollectors, int from, int to) throws org.apache.lucene.queryparser.classic.ParseException
conditions
- a list of conditions to construct a query from.facetCollectors
- Facet collectors to apply to the query result. Can
be Collections.EMPTY_LIST
, if not used.sortSpecification
- Specifies the sort order. Can be null, if not
used.from
- return results starting from this index (inclusive).to
- return results until this index (exclusive).org.apache.lucene.queryparser.classic.ParseException
- when the resulting query is illegal.public void finalize() throws Throwable
protected void scheduleForReindex(Resource resource)
resource
- the resource to index.protected void processDefinitions()
protected void indexResource(Resource resource, org.apache.lucene.index.IndexWriter writer)
resource
- the resource to index.writer
- the index writer.Copyright © 2014 The Apache Software Foundation. All Rights Reserved.