public class Lucene extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Lucene.EarlyTerminatingCollector
A collector that terminates early by throwing
Lucene.EarlyTerminationException
when count of matched documents has reached maxCountHits |
static class |
Lucene.EarlyTerminationException
This exception is thrown when
Lucene.EarlyTerminatingCollector
reaches early termination |
Modifier and Type | Field and Description |
---|---|
static org.apache.lucene.util.Version |
ANALYZER_VERSION |
static org.apache.lucene.search.ScoreDoc[] |
EMPTY_SCORE_DOCS |
static org.apache.lucene.search.TopDocs |
EMPTY_TOP_DOCS |
static NamedAnalyzer |
KEYWORD_ANALYZER |
static String |
LATEST_POSTINGS_FORMAT |
static org.apache.lucene.util.Version |
QUERYPARSER_VERSION |
static NamedAnalyzer |
STANDARD_ANALYZER |
static org.apache.lucene.util.Version |
VERSION |
Modifier and Type | Method and Description |
---|---|
static void |
checkSegmentInfoIntegrity(org.apache.lucene.store.Directory directory) |
static void |
cleanLuceneIndex(org.apache.lucene.store.Directory directory)
This method removes all lucene files from the given directory.
|
static long |
count(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Query query) |
static long |
count(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Query query,
int terminateAfterCount)
Performs a count on the
searcher for query . |
static boolean |
countWithEarlyTermination(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Filter filter,
org.apache.lucene.search.Query query,
Lucene.EarlyTerminatingCollector collector)
Performs a count on
query and filter with early termination using searcher . |
static boolean |
countWithEarlyTermination(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Query query,
Lucene.EarlyTerminatingCollector collector)
Calls
countWithEarlyTermination(searcher, null, query, collector) |
static Lucene.EarlyTerminatingCollector |
createCountBasedEarlyTerminatingCollector(int maxCountHits)
Creates count based early termination collector with a threshold of
maxCountHits |
static Lucene.EarlyTerminatingCollector |
createExistsCollector()
Creates an
Lucene.EarlyTerminatingCollector
with a threshold of 1 |
static boolean |
exists(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Query query,
org.apache.lucene.search.Filter filter,
Lucene.EarlyTerminatingCollector collector)
Performs an exists (count > 0) query on the
searcher for query
with filter using the given collector
The collector can be instantiated using Lucene.createExistsCollector() |
static boolean |
exists(org.apache.lucene.search.IndexSearcher searcher,
org.apache.lucene.search.Query query,
Lucene.EarlyTerminatingCollector collector)
Performs an exists (count > 0) query on the
searcher for query
using the given collector
The collector can be instantiated using Lucene.createExistsCollector() |
static Iterable<String> |
files(org.apache.lucene.index.SegmentInfos infos)
Returns an iterable that allows to iterate over all files in this segments info
|
static boolean |
indexExists(org.apache.lucene.store.Directory directory) |
static boolean |
isCorruptionException(Throwable t)
Returns true iff the given exception or
one of it's causes is an instance of
CorruptIndexException otherwise false. |
static org.apache.lucene.util.Version |
parseVersion(String version,
org.apache.lucene.util.Version defaultVersion,
ESLogger logger) |
static org.apache.lucene.util.Version |
parseVersionLenient(String toParse,
org.apache.lucene.util.Version defaultValue)
Parses the version string lenient and returns the the default value if the given string is null or emtpy
|
static org.apache.lucene.index.SegmentInfos |
pruneUnreferencedFiles(String segmentsFileName,
org.apache.lucene.store.Directory directory)
This method removes all files from the given directory that are not referenced by the given segments file.
|
static org.apache.lucene.search.Explanation |
readExplanation(StreamInput in) |
static org.apache.lucene.search.FieldDoc |
readFieldDoc(StreamInput in) |
static org.apache.lucene.search.ScoreDoc |
readScoreDoc(StreamInput in) |
static org.apache.lucene.index.SegmentInfos |
readSegmentInfos(org.apache.lucene.store.Directory directory)
Reads the segments infos, failing if it fails to load
|
static org.apache.lucene.index.SegmentInfos |
readSegmentInfos(org.apache.lucene.index.IndexCommit commit,
org.apache.lucene.store.Directory directory)
Reads the segments infos from the given commit, failing if it fails to load
|
static org.apache.lucene.search.SortField.Type |
readSortType(StreamInput in) |
static org.apache.lucene.search.TopDocs |
readTopDocs(StreamInput in) |
static boolean |
safeClose(org.apache.lucene.index.IndexWriter writer)
Closes the index writer, returning false if it failed to close.
|
static boolean |
upgradeLucene3xSegmentsMetadata(org.apache.lucene.store.Directory directory)
Upgrades the segments metadata of the index to match a lucene 4.x index format.
|
static boolean |
waitForIndex(org.apache.lucene.store.Directory directory,
long timeLimitMillis)
Wait for an index to exist for up to
timeLimitMillis . |
static Lucene.EarlyTerminatingCollector |
wrapCountBasedEarlyTerminatingCollector(org.apache.lucene.search.Collector delegate,
int maxCountHits)
Wraps
delegate with count based early termination collector with a threshold of maxCountHits |
static org.apache.lucene.search.TimeLimitingCollector |
wrapTimeLimitingCollector(org.apache.lucene.search.Collector delegate,
org.apache.lucene.util.Counter counter,
long timeoutInMillis)
Wraps
delegate with a time limited collector with a timeout of timeoutInMillis |
static void |
writeExplanation(StreamOutput out,
org.apache.lucene.search.Explanation explanation) |
static void |
writeFieldDoc(StreamOutput out,
org.apache.lucene.search.FieldDoc fieldDoc) |
static void |
writeScoreDoc(StreamOutput out,
org.apache.lucene.search.ScoreDoc scoreDoc) |
static void |
writeSortType(StreamOutput out,
org.apache.lucene.search.SortField.Type sortType) |
static void |
writeTopDocs(StreamOutput out,
org.apache.lucene.search.TopDocs topDocs,
int from) |
public static final org.apache.lucene.util.Version VERSION
public static final org.apache.lucene.util.Version ANALYZER_VERSION
public static final org.apache.lucene.util.Version QUERYPARSER_VERSION
public static final String LATEST_POSTINGS_FORMAT
public static final NamedAnalyzer STANDARD_ANALYZER
public static final NamedAnalyzer KEYWORD_ANALYZER
public static final org.apache.lucene.search.ScoreDoc[] EMPTY_SCORE_DOCS
public static final org.apache.lucene.search.TopDocs EMPTY_TOP_DOCS
public static org.apache.lucene.util.Version parseVersion(@Nullable String version, org.apache.lucene.util.Version defaultVersion, ESLogger logger)
public static org.apache.lucene.index.SegmentInfos readSegmentInfos(org.apache.lucene.store.Directory directory) throws IOException
IOException
public static Iterable<String> files(org.apache.lucene.index.SegmentInfos infos) throws IOException
IOException
public static org.apache.lucene.index.SegmentInfos readSegmentInfos(org.apache.lucene.index.IndexCommit commit, org.apache.lucene.store.Directory directory) throws IOException
IOException
public static org.apache.lucene.index.SegmentInfos pruneUnreferencedFiles(String segmentsFileName, org.apache.lucene.store.Directory directory) throws IOException
IOException
public static void cleanLuceneIndex(org.apache.lucene.store.Directory directory) throws IOException
IOException
public static void checkSegmentInfoIntegrity(org.apache.lucene.store.Directory directory) throws IOException
IOException
public static long count(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query) throws IOException
IOException
public static long count(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, int terminateAfterCount) throws IOException
searcher
for query
. Terminates
early when the count has reached terminateAfter
IOException
public static final Lucene.EarlyTerminatingCollector createCountBasedEarlyTerminatingCollector(int maxCountHits)
maxCountHits
public static final Lucene.EarlyTerminatingCollector wrapCountBasedEarlyTerminatingCollector(org.apache.lucene.search.Collector delegate, int maxCountHits)
delegate
with count based early termination collector with a threshold of maxCountHits
public static final org.apache.lucene.search.TimeLimitingCollector wrapTimeLimitingCollector(org.apache.lucene.search.Collector delegate, org.apache.lucene.util.Counter counter, long timeoutInMillis)
delegate
with a time limited collector with a timeout of timeoutInMillis
public static boolean exists(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.apache.lucene.search.Filter filter, Lucene.EarlyTerminatingCollector collector) throws IOException
searcher
for query
with filter
using the given collector
The collector
can be instantiated using Lucene.createExistsCollector()
IOException
public static boolean exists(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, Lucene.EarlyTerminatingCollector collector) throws IOException
searcher
for query
using the given collector
The collector
can be instantiated using Lucene.createExistsCollector()
IOException
public static boolean countWithEarlyTermination(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, Lucene.EarlyTerminatingCollector collector) throws IOException
countWithEarlyTermination(searcher, null, query, collector)
IOException
public static boolean countWithEarlyTermination(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Filter filter, org.apache.lucene.search.Query query, Lucene.EarlyTerminatingCollector collector) throws IOException
query
and filter
with early termination using searcher
.
The early termination threshold is specified by the provided collector
IOException
public static final Lucene.EarlyTerminatingCollector createExistsCollector()
Lucene.EarlyTerminatingCollector
with a threshold of 1
public static boolean safeClose(org.apache.lucene.index.IndexWriter writer)
public static org.apache.lucene.search.TopDocs readTopDocs(StreamInput in) throws IOException
IOException
public static org.apache.lucene.search.FieldDoc readFieldDoc(StreamInput in) throws IOException
IOException
public static org.apache.lucene.search.ScoreDoc readScoreDoc(StreamInput in) throws IOException
IOException
public static void writeTopDocs(StreamOutput out, org.apache.lucene.search.TopDocs topDocs, int from) throws IOException
IOException
public static void writeFieldDoc(StreamOutput out, org.apache.lucene.search.FieldDoc fieldDoc) throws IOException
IOException
public static void writeScoreDoc(StreamOutput out, org.apache.lucene.search.ScoreDoc scoreDoc) throws IOException
IOException
public static org.apache.lucene.search.SortField.Type readSortType(StreamInput in) throws IOException
IOException
public static void writeSortType(StreamOutput out, org.apache.lucene.search.SortField.Type sortType) throws IOException
IOException
public static org.apache.lucene.search.Explanation readExplanation(StreamInput in) throws IOException
IOException
public static void writeExplanation(StreamOutput out, org.apache.lucene.search.Explanation explanation) throws IOException
IOException
public static final boolean indexExists(org.apache.lucene.store.Directory directory) throws IOException
IOException
public static final boolean waitForIndex(org.apache.lucene.store.Directory directory, long timeLimitMillis) throws IOException
timeLimitMillis
. Returns
true if the index eventually exists, false if not.
Will retry the directory every second for at least timeLimitMillis
IOException
public static boolean isCorruptionException(Throwable t)
CorruptIndexException
otherwise false.public static org.apache.lucene.util.Version parseVersionLenient(String toParse, org.apache.lucene.util.Version defaultValue)
public static boolean upgradeLucene3xSegmentsMetadata(org.apache.lucene.store.Directory directory) throws IOException
IOException
Copyright © 2009–2015. All rights reserved.