Package org.apache.lucene.monitor
Class Monitor
java.lang.Object
org.apache.lucene.monitor.Monitor
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Statistics for the query cache and query index -
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a non-persistent Monitor instance with the default term-filtering PresearcherMonitor
(Analyzer analyzer, MonitorConfiguration config) Create a new Monitor instance with a specific configurationMonitor
(Analyzer analyzer, Presearcher presearcher) Create a new non-persistent Monitor instanceMonitor
(Analyzer analyzer, Presearcher presearcher, MonitorConfiguration configuration) Create a new Monitor instance -
Method Summary
Modifier and TypeMethodDescriptionvoid
Register aMonitorUpdateListener
that will be notified whenever changes are made to the Monitor's queryindexvoid
clear()
Delete all queries from the monitorvoid
close()
<T extends QueryMatch>
PresearcherMatches<T>debug
(Document[] docs, MatcherFactory<T> factory) Match a DocumentBatch against the queries stored in the Monitor, also returning information about which queries were selected by the presearcher, and why.<T extends QueryMatch>
PresearcherMatches<T>debug
(Document doc, MatcherFactory<T> factory) Match a singleDocument
against the queries stored in the Monitor, also returning information about which queries were selected by the presearcher, and why.void
deleteById
(String... queryIds) Delete queries from the monitor by IDvoid
deleteById
(List<String> queryIds) Delete queries from the monitor by IDint
Get the MonitorQuery for a given query idint
<T extends QueryMatch>
MultiMatchingQueries<T>match
(Document[] docs, MatcherFactory<T> factory) Match an array ofDocument
s against the queryindex, calling aCandidateMatcher
produced by the suppliedMatcherFactory
for each possible matching query.<T extends QueryMatch>
MatchingQueries<T>match
(Document doc, MatcherFactory<T> factory) Match a singleDocument
against the queryindex, calling aCandidateMatcher
produced by the suppliedMatcherFactory
for each possible matching query.void
Remove unused queries from the query cache.void
register
(Iterable<MonitorQuery> queries) Add new queries to the monitorvoid
register
(MonitorQuery... queries) Add new queries to the monitor
-
Field Details
-
presearcher
-
-
Constructor Details
-
Monitor
Create a non-persistent Monitor instance with the default term-filtering Presearcher- Parameters:
analyzer
- to analyzeDocument
s at match time- Throws:
IOException
-
Monitor
Create a new non-persistent Monitor instance- Parameters:
analyzer
- to analyzeDocument
s at match timepresearcher
- the presearcher to use- Throws:
IOException
-
Monitor
Create a new Monitor instance with a specific configuration- Parameters:
analyzer
- to analyzeDocument
s at match timeconfig
- the configuration- Throws:
IOException
-
Monitor
public Monitor(Analyzer analyzer, Presearcher presearcher, MonitorConfiguration configuration) throws IOException Create a new Monitor instance- Parameters:
analyzer
- to analyzeDocument
s at match timepresearcher
- the presearcher to useconfiguration
- the configuration- Throws:
IOException
-
-
Method Details
-
addQueryIndexUpdateListener
Register aMonitorUpdateListener
that will be notified whenever changes are made to the Monitor's queryindex- Parameters:
listener
- listener to register
-
getQueryCacheStats
- Returns:
- Statistics for the internal query index and cache
-
purgeCache
Remove unused queries from the query cache.This is normally called from a background thread at a rate set by configurePurgeFrequency().
- Throws:
IOException
- on IO errors
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
register
Add new queries to the monitor- Parameters:
queries
- the MonitorQueries to add- Throws:
IOException
-
register
Add new queries to the monitor- Parameters:
queries
- the MonitorQueries to add- Throws:
IOException
- on IO errors
-
deleteById
Delete queries from the monitor by ID- Parameters:
queryIds
- the IDs to delete- Throws:
IOException
- on IO errors
-
deleteById
Delete queries from the monitor by ID- Parameters:
queryIds
- the IDs to delete- Throws:
IOException
- on IO errors
-
clear
Delete all queries from the monitor- Throws:
IOException
- on IO errors
-
match
public <T extends QueryMatch> MultiMatchingQueries<T> match(Document[] docs, MatcherFactory<T> factory) throws IOException Match an array ofDocument
s against the queryindex, calling aCandidateMatcher
produced by the suppliedMatcherFactory
for each possible matching query.- Type Parameters:
T
- the type ofQueryMatch
to return- Parameters:
docs
- the DocumentBatch to matchfactory
- aMatcherFactory
to use to create aCandidateMatcher
for the match run- Returns:
- a
MatchingQueries
object summarizing the match run. - Throws:
IOException
- on IO errors
-
match
public <T extends QueryMatch> MatchingQueries<T> match(Document doc, MatcherFactory<T> factory) throws IOException Match a singleDocument
against the queryindex, calling aCandidateMatcher
produced by the suppliedMatcherFactory
for each possible matching query.- Type Parameters:
T
- the type ofQueryMatch
to return- Parameters:
doc
- the InputDocument to matchfactory
- aMatcherFactory
to use to create aCandidateMatcher
for the match run- Returns:
- a
MatchingQueries
object summarizing the match run. - Throws:
IOException
- on IO errors
-
getQuery
Get the MonitorQuery for a given query id- Parameters:
queryId
- the id of the query to get- Returns:
- the MonitorQuery stored for this id, or null if not found
- Throws:
IOException
- on IO errorsIllegalStateException
- if queries are not stored in the queryindex
-
getDisjunctCount
public int getDisjunctCount()- Returns:
- the number of queries (after decomposition) stored in this Monitor
-
getQueryCount
- Returns:
- the number of queries stored in this Monitor
- Throws:
IOException
- on IO errors
-
getQueryIds
- Returns:
- the set of query ids of the queries stored in this Monitor
- Throws:
IOException
- on IO errors
-
debug
public <T extends QueryMatch> PresearcherMatches<T> debug(Document[] docs, MatcherFactory<T> factory) throws IOException Match a DocumentBatch against the queries stored in the Monitor, also returning information about which queries were selected by the presearcher, and why.- Type Parameters:
T
- the type of QueryMatch produced by the CandidateMatcher- Parameters:
docs
- a DocumentBatch to match against the indexfactory
- aMatcherFactory
to use to create aCandidateMatcher
for the match run- Returns:
- a
PresearcherMatches
object containing debug information - Throws:
IOException
- on IO errors
-
debug
public <T extends QueryMatch> PresearcherMatches<T> debug(Document doc, MatcherFactory<T> factory) throws IOException Match a singleDocument
against the queries stored in the Monitor, also returning information about which queries were selected by the presearcher, and why.- Type Parameters:
T
- the type of QueryMatch produced by the CandidateMatcher- Parameters:
doc
- an InputDocument to match against the indexfactory
- aMatcherFactory
to use to create aCandidateMatcher
for the match run- Returns:
- a
PresearcherMatches
object containing debug information - Throws:
IOException
- on IO errors
-