Class QueryInsightsService
java.lang.Object
org.opensearch.common.lifecycle.AbstractLifecycleComponent
org.opensearch.plugin.insights.core.service.QueryInsightsService
- All Implemented Interfaces:
Closeable,AutoCloseable,org.opensearch.common.lease.Releasable,org.opensearch.common.lifecycle.LifecycleComponent
public class QueryInsightsService
extends org.opensearch.common.lifecycle.AbstractLifecycleComponent
Service responsible for gathering, analyzing, storing and exporting
information related to search queries
- Opensearch.internal:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Scheduler.CancellableHolds a reference to delayed operationScheduler.Cancellableso it can be cancelled when the service closed concurrently.Fields inherited from class org.opensearch.common.lifecycle.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsConstructorDescriptionQueryInsightsService(ThreadPool threadPool) Constructor of the QueryInsightsService -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRecord(SearchQueryRecord record) Ingest the query data into in-memory storesprotected voiddoClose()protected voiddoStart()protected voiddoStop()voidDrain the queryRecordsQueue into internal stores and servicesvoidenableCollection(MetricType metricType, boolean enable) Set flag to enable or disable Query Insights data collectiongetTopQueriesService(MetricType metricType) Get the top queries service based on metricTypebooleanisCollectionEnabled(MetricType metricType) Get if the Query Insights data collection is enabled for a MetricTypebooleanCheck if query insights service is enabledMethods inherited from class org.opensearch.common.lifecycle.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
-
Field Details
-
scheduledFuture
Holds a reference to delayed operationScheduler.Cancellableso it can be cancelled when the service closed concurrently.
-
-
Constructor Details
-
QueryInsightsService
Constructor of the QueryInsightsService- Parameters:
threadPool- The OpenSearch thread pool to run async tasks
-
-
Method Details
-
addRecord
Ingest the query data into in-memory stores- Parameters:
record- the record to ingest
-
drainRecords
public void drainRecords()Drain the queryRecordsQueue into internal stores and services -
getTopQueriesService
Get the top queries service based on metricType- Parameters:
metricType-MetricType- Returns:
TopQueriesService
-
enableCollection
Set flag to enable or disable Query Insights data collection- Parameters:
metricType-MetricTypeenable- Flag to enable or disable Query Insights data collection
-
isCollectionEnabled
Get if the Query Insights data collection is enabled for a MetricType- Parameters:
metricType-MetricType- Returns:
- if the Query Insights data collection is enabled
-
isEnabled
public boolean isEnabled()Check if query insights service is enabled- Returns:
- if query insights service is enabled
-
doStart
protected void doStart()- Specified by:
doStartin classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStopin classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClosein classorg.opensearch.common.lifecycle.AbstractLifecycleComponent
-