Class SearchQueryRecord

java.lang.Object
org.opensearch.plugin.insights.rules.model.SearchQueryRecord
All Implemented Interfaces:
org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject

public class SearchQueryRecord extends Object implements org.opensearch.core.xcontent.ToXContentObject, org.opensearch.core.common.io.stream.Writeable
SearchQueryRecord represents a minimal atomic record stored in the Query Insight Framework, which contains extensive information related to a search query.
Opensearch.internal:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent

    org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable

    org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
  • Field Summary

    Fields inherited from interface org.opensearch.core.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    SearchQueryRecord(long timestamp, Map<MetricType,Number> measurements, Map<Attribute,Object> attributes)
    Constructor of SearchQueryRecord
    SearchQueryRecord(org.opensearch.core.common.io.stream.StreamInput in)
    Constructor of SearchQueryRecord
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttribute(Attribute attribute, Object value)
    Add an attribute to this record
    static int
    Compare two SearchQueryRecord, based on the given MetricType
    boolean
    Check if a SearchQueryRecord is deep equal to another record
    Returns a map of the attributes associated with the metric.
    Returns the measurement associated with the specified name.
    Returns a map of all the measurements associated with the metric.
    long
    Returns the observation time of the metric.
    int
     
    org.opensearch.core.xcontent.XContentBuilder
    toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params)
     
    void
    writeTo(org.opensearch.core.common.io.stream.StreamOutput out)
    Write a SearchQueryRecord to a StreamOutput

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.opensearch.core.xcontent.ToXContentObject

    isFragment
  • Constructor Details

    • SearchQueryRecord

      public SearchQueryRecord(org.opensearch.core.common.io.stream.StreamInput in) throws IOException, ClassCastException
      Constructor of SearchQueryRecord
      Parameters:
      in - the StreamInput to read the SearchQueryRecord from
      Throws:
      IOException - IOException
      ClassCastException - ClassCastException
    • SearchQueryRecord

      public SearchQueryRecord(long timestamp, Map<MetricType,Number> measurements, Map<Attribute,Object> attributes)
      Constructor of SearchQueryRecord
      Parameters:
      timestamp - The timestamp of the query.
      measurements - A list of Measurement associated with this query
      attributes - A list of Attributes associated with this query
  • Method Details

    • getTimestamp

      public long getTimestamp()
      Returns the observation time of the metric.
      Returns:
      the observation time in milliseconds
    • getMeasurement

      public Number getMeasurement(MetricType name)
      Returns the measurement associated with the specified name.
      Parameters:
      name - the name of the measurement
      Returns:
      the measurement object, or null if not found
    • getMeasurements

      public Map<MetricType,Number> getMeasurements()
      Returns a map of all the measurements associated with the metric.
      Returns:
      a map of measurement names to measurement objects
    • getAttributes

      public Map<Attribute,Object> getAttributes()
      Returns a map of the attributes associated with the metric.
      Returns:
      a map of attribute keys to attribute values
    • addAttribute

      public void addAttribute(Attribute attribute, Object value)
      Add an attribute to this record
      Parameters:
      attribute - attribute to add
      value - the value associated with the attribute
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • writeTo

      public void writeTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException
      Write a SearchQueryRecord to a StreamOutput
      Specified by:
      writeTo in interface org.opensearch.core.common.io.stream.Writeable
      Parameters:
      out - the StreamOutput to write
      Throws:
      IOException - IOException
    • compare

      public static int compare(SearchQueryRecord a, SearchQueryRecord b, MetricType metricType)
      Compare two SearchQueryRecord, based on the given MetricType
      Parameters:
      a - the first SearchQueryRecord to compare
      b - the second SearchQueryRecord to compare
      metricType - the MetricType to compare on
      Returns:
      0 if the first SearchQueryRecord is numerically equal to the second SearchQueryRecord; -1 if the first SearchQueryRecord is numerically less than the second SearchQueryRecord; 1 if the first SearchQueryRecord is numerically greater than the second SearchQueryRecord.
    • equals

      public boolean equals(Object o)
      Check if a SearchQueryRecord is deep equal to another record
      Overrides:
      equals in class Object
      Parameters:
      o - the other SearchQueryRecord record
      Returns:
      true if two records are deep equal, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object