public class LuceneIndex extends AbstractLuceneIndex
LuceneSail| Modifier and Type | Field and Description |
|---|---|
protected ReaderMonitor |
currentMonitor
This holds IndexReader and IndexSearcher.
|
oldmonitorsmaxDocs, wktFields| Constructor and Description |
|---|
LuceneIndex() |
LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer)
Constructor for keeping backwards compatibility.
|
LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer,
org.apache.lucene.search.similarities.Similarity similarity)
Creates a new LuceneIndex.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addContextField(String context,
org.apache.lucene.document.Document document)
Add the "context" value to the doc
|
protected void |
addDocument(SearchDocument doc) |
static void |
addIDField(String id,
org.apache.lucene.document.Document document)
Stores and indexes an ID in a Document.
|
static void |
addPredicateField(String predicate,
String text,
org.apache.lucene.document.Document document) |
static void |
addResourceField(String resourceId,
org.apache.lucene.document.Document document)
Stores and indexes the resource ID in a Document.
|
static void |
addStoredOnlyPredicateField(String predicate,
String text,
org.apache.lucene.document.Document document) |
static void |
addTextField(String text,
org.apache.lucene.document.Document document) |
void |
begin()
Begins a transaction.
|
void |
clear()
Clears the indexes.
|
void |
clearContexts(Resource... contexts)
This should be called from within a begin-commit-rollback block.
|
void |
commit()
Commits any changes done to the LuceneIndex since the last commit.
|
protected SearchDocument |
copyDocument(SearchDocument doc) |
protected org.apache.lucene.analysis.Analyzer |
createAnalyzer(Properties parameters) |
protected org.apache.lucene.store.Directory |
createDirectory(Properties parameters) |
protected org.apache.lucene.search.similarities.Similarity |
createSimilarity(Properties parameters) |
protected com.google.common.base.Function<String,? extends org.apache.lucene.spatial.SpatialStrategy> |
createSpatialStrategyMapper(Map<String,String> parameters) |
protected void |
deleteDocument(SearchDocument doc) |
protected Iterable<? extends DocumentDistance> |
geoQuery(IRI geoProperty,
org.locationtech.spatial4j.shape.Point p,
IRI units,
double distance,
String distanceVar,
Var contextVar) |
protected Iterable<? extends DocumentResult> |
geoRelationQuery(String relation,
IRI geoProperty,
String wkt,
Var contextVar) |
org.apache.lucene.analysis.Analyzer |
getAnalyzer() |
ReaderMonitor |
getCurrentMonitor()
Current monitor holds instance of IndexReader and IndexSearcher It is used to keep track of readers
|
org.apache.lucene.store.Directory |
getDirectory() |
org.apache.lucene.document.Document |
getDocument(int docId,
Set<String> fieldsToLoad)
Returns the lucene hit with the given id of the respective lucene query
|
org.apache.lucene.document.Document |
getDocument(Resource subject,
Resource context)
Returns a Document representing the specified Resource and Context combination, or null when no such Document
exists yet.
|
protected SearchDocument |
getDocument(String id) |
List<org.apache.lucene.document.Document> |
getDocuments(Resource subject)
Returns a list of Documents representing the specified Resource (empty when no such Document exists yet).Each
document represent a set of statements with the specified Resource as a subject, which are stored in a specific
context
|
protected Iterable<? extends SearchDocument> |
getDocuments(String resourceId) |
org.apache.lucene.index.IndexReader |
getIndexReader() |
org.apache.lucene.search.IndexSearcher |
getIndexSearcher() |
org.apache.lucene.index.IndexWriter |
getIndexWriter() |
String |
getSnippet(String fieldName,
String text,
org.apache.lucene.search.highlight.Highlighter highlighter) |
protected org.locationtech.spatial4j.context.SpatialContext |
getSpatialContext(String property) |
com.google.common.base.Function<? super String,? extends org.apache.lucene.spatial.SpatialStrategy> |
getSpatialStrategyMapper() |
void |
initialize(Properties parameters) |
protected BulkUpdater |
newBulkUpdate() |
protected SearchDocument |
newDocument(String id,
String resourceId,
String context) |
protected SearchQuery |
parseQuery(String query,
IRI propertyURI)
Deprecated.
|
protected Iterable<? extends DocumentScore> |
query(Resource subject,
String query,
IRI propertyURI,
boolean highlight)
Parse the passed query.
|
void |
rollback() |
org.apache.lucene.search.TopDocs |
search(org.apache.lucene.search.Query query)
Evaluates the given query and returns the results as a TopDocs instance.
|
org.apache.lucene.search.TopDocs |
search(Resource resource,
org.apache.lucene.search.Query query)
Evaluates the given query only for the given resource.
|
void |
shutDown() |
protected void |
updateDocument(SearchDocument doc) |
beginReading, endReading, getOldMonitorsaccept, addDocuments, addRemoveStatements, addStatement, evaluate, evaluate, getResource, isGeoField, parseLuceneQueryShape, parseQueryPoint, parseQueryShape, removeStatementprotected volatile ReaderMonitor currentMonitor
public LuceneIndex()
public LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer)
throws IOException
directory - analyzer - IOExceptionpublic LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer,
org.apache.lucene.search.similarities.Similarity similarity)
throws IOException
directory - The Directory in which an index can be found and/or in which index files are written.analyzer - The Analyzer that will be used for tokenizing strings to index and queries.similarity - The Similarity that will be used for scoring.IOException - When the Directory could not be unlocked.public void initialize(Properties parameters) throws Exception
initialize in interface SearchIndexinitialize in class AbstractSearchIndexExceptionprotected org.apache.lucene.store.Directory createDirectory(Properties parameters) throws IOException
IOExceptionprotected org.apache.lucene.analysis.Analyzer createAnalyzer(Properties parameters) throws Exception
Exceptionprotected org.apache.lucene.search.similarities.Similarity createSimilarity(Properties parameters) throws Exception
Exceptionprotected com.google.common.base.Function<String,? extends org.apache.lucene.spatial.SpatialStrategy> createSpatialStrategyMapper(Map<String,String> parameters)
protected org.locationtech.spatial4j.context.SpatialContext getSpatialContext(String property)
getSpatialContext in class AbstractSearchIndexpublic org.apache.lucene.store.Directory getDirectory()
public org.apache.lucene.analysis.Analyzer getAnalyzer()
public com.google.common.base.Function<? super String,? extends org.apache.lucene.spatial.SpatialStrategy> getSpatialStrategyMapper()
public org.apache.lucene.index.IndexReader getIndexReader()
throws IOException
IOExceptionpublic org.apache.lucene.search.IndexSearcher getIndexSearcher()
throws IOException
IOExceptionpublic ReaderMonitor getCurrentMonitor()
getCurrentMonitor in class AbstractLuceneIndexpublic org.apache.lucene.index.IndexWriter getIndexWriter()
throws IOException
IOExceptionpublic void shutDown()
throws IOException
IOExceptionprotected SearchDocument getDocument(String id) throws IOException
getDocument in class AbstractSearchIndexIOExceptionprotected Iterable<? extends SearchDocument> getDocuments(String resourceId) throws IOException
getDocuments in class AbstractSearchIndexIOExceptionprotected SearchDocument newDocument(String id, String resourceId, String context)
newDocument in class AbstractSearchIndexprotected SearchDocument copyDocument(SearchDocument doc)
copyDocument in class AbstractSearchIndexprotected void addDocument(SearchDocument doc) throws IOException
addDocument in class AbstractSearchIndexIOExceptionprotected void updateDocument(SearchDocument doc) throws IOException
updateDocument in class AbstractSearchIndexIOExceptionprotected void deleteDocument(SearchDocument doc) throws IOException
deleteDocument in class AbstractSearchIndexIOExceptionprotected BulkUpdater newBulkUpdate()
newBulkUpdate in class AbstractSearchIndexpublic org.apache.lucene.document.Document getDocument(Resource subject, Resource context) throws IOException
subject - context - IOExceptionpublic List<org.apache.lucene.document.Document> getDocuments(Resource subject) throws IOException
subject - IOExceptionpublic static void addIDField(String id, org.apache.lucene.document.Document document)
id - document - public static void addContextField(String context, org.apache.lucene.document.Document document)
context - the context or null, if null-contextdocument - the documentpublic static void addResourceField(String resourceId, org.apache.lucene.document.Document document)
resourceId - document - public static void addPredicateField(String predicate, String text, org.apache.lucene.document.Document document)
public static void addStoredOnlyPredicateField(String predicate, String text, org.apache.lucene.document.Document document)
public static void addTextField(String text, org.apache.lucene.document.Document document)
public void begin()
throws IOException
SearchIndexIOExceptionpublic void commit()
throws IOException
IOExceptionpublic void rollback()
throws IOException
IOException@Deprecated protected SearchQuery parseQuery(String query, IRI propertyURI) throws MalformedQueryException
parseQuery in class AbstractSearchIndexquery - stringorg.apache.lucene.queryparser.classic.ParseException - when the parsing brakesMalformedQueryExceptionprotected Iterable<? extends DocumentScore> query(Resource subject, String query, IRI propertyURI, boolean highlight) throws MalformedQueryException, IOException
query in class AbstractSearchIndexquery - stringorg.apache.lucene.queryparser.classic.ParseException - when the parsing brakesMalformedQueryExceptionIOExceptionprotected Iterable<? extends DocumentDistance> geoQuery(IRI geoProperty, org.locationtech.spatial4j.shape.Point p, IRI units, double distance, String distanceVar, Var contextVar) throws MalformedQueryException, IOException
geoQuery in class AbstractSearchIndexMalformedQueryExceptionIOExceptionprotected Iterable<? extends DocumentResult> geoRelationQuery(String relation, IRI geoProperty, String wkt, Var contextVar) throws MalformedQueryException, IOException
geoRelationQuery in class AbstractSearchIndexMalformedQueryExceptionIOExceptionpublic org.apache.lucene.document.Document getDocument(int docId,
Set<String> fieldsToLoad)
docId - the id of the document to returnfieldsToLoad - public String getSnippet(String fieldName, String text, org.apache.lucene.search.highlight.Highlighter highlighter)
public org.apache.lucene.search.TopDocs search(Resource resource, org.apache.lucene.search.Query query) throws IOException
resource - query - IOExceptionpublic org.apache.lucene.search.TopDocs search(org.apache.lucene.search.Query query)
throws IOException
query - IOExceptionpublic void clearContexts(Resource... contexts) throws IOException
SearchIndexcontexts - IOExceptionpublic void clear()
throws IOException
SearchIndexIOExceptionCopyright © 2015-2021 Eclipse Foundation. All Rights Reserved.