public class LuceneIndex extends AbstractLuceneIndex
LuceneSail| Modifier and Type | Field and Description |
|---|---|
protected ReaderMonitor |
currentMonitor
This holds IndexReader and IndexSearcher.
|
static String |
GEOHASH_FIELD_PREFIX |
oldmonitorsmaxDocs, wktFields| Constructor and Description |
|---|
LuceneIndex() |
LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer)
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 com.google.common.base.Function<String,? extends SpatialStrategy> |
createSpatialStrategyMapper(Map<String,String> parameters) |
protected void |
deleteDocument(SearchDocument doc) |
protected Iterable<? extends DocumentDistance> |
geoQuery(URI geoProperty,
com.spatial4j.core.shape.Point p,
URI units,
double distance,
String distanceVar,
Var contextVar) |
protected Iterable<? extends DocumentResult> |
geoRelationQuery(String relation,
URI geoProperty,
com.spatial4j.core.shape.Shape shape,
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 & 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).
|
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 com.spatial4j.core.context.SpatialContext |
getSpatialContext(String property) |
com.google.common.base.Function<? super String,? extends SpatialStrategy> |
getSpatialStrategyMapper() |
void |
initialize(Properties parameters) |
protected BulkUpdater |
newBulkUpdate() |
protected SearchDocument |
newDocument(String id,
String resourceId,
String context) |
protected SearchQuery |
parseQuery(String query,
URI propertyURI)
Deprecated.
|
protected Iterable<? extends DocumentScore> |
query(Resource subject,
String query,
URI 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, parseQueryShape, removeStatementpublic static final String GEOHASH_FIELD_PREFIX
protected ReaderMonitor currentMonitor
public LuceneIndex()
public LuceneIndex(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer)
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.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 com.google.common.base.Function<String,? extends SpatialStrategy> createSpatialStrategyMapper(Map<String,String> parameters)
protected com.spatial4j.core.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 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
IOExceptionpublic List<org.apache.lucene.document.Document> getDocuments(Resource subject) throws IOException
IOExceptionpublic static void addIDField(String id, org.apache.lucene.document.Document document)
public static void addContextField(String context, org.apache.lucene.document.Document document)
context - the context or null, if null-contextdocument - the documentifNotExists - check if this context existspublic static void addResourceField(String resourceId, org.apache.lucene.document.Document 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, URI propertyURI) throws MalformedQueryException
parseQuery in class AbstractSearchIndexquery - stringorg.apache.lucene.queryParser.ParseException - when the parsing brakesMalformedQueryExceptionprotected Iterable<? extends DocumentScore> query(Resource subject, String query, URI propertyURI, boolean highlight) throws MalformedQueryException, IOException
query in class AbstractSearchIndexquery - stringorg.apache.lucene.queryParser.ParseException - when the parsing brakesMalformedQueryExceptionIOExceptionprotected Iterable<? extends DocumentDistance> geoQuery(URI geoProperty, com.spatial4j.core.shape.Point p, URI units, double distance, String distanceVar, Var contextVar) throws MalformedQueryException, IOException
geoQuery in class AbstractSearchIndexMalformedQueryExceptionIOExceptionprotected Iterable<? extends DocumentResult> geoRelationQuery(String relation, URI geoProperty, com.spatial4j.core.shape.Shape shape, Var contextVar) throws MalformedQueryException, IOException
geoRelationQuery in class AbstractSearchIndexMalformedQueryExceptionIOExceptionpublic org.apache.lucene.document.Document getDocument(int docId,
Set<String> fieldsToLoad)
id - the id of the document to returnpublic 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
IOExceptionpublic org.apache.lucene.search.TopDocs search(org.apache.lucene.search.Query query)
throws IOException
IOExceptionpublic void clearContexts(Resource... contexts) throws IOException
SearchIndexcontexts - sail - - the underlying native sail where to read the missing triples from
after deletionSailExceptionIOExceptionpublic void clear()
throws IOException
SearchIndexIOExceptionCopyright © 2001–2015 Aduna. All rights reserved.