Class SearchRequestMap

java.lang.Object
org.opensearch.search.pipeline.common.helpers.SearchRequestMap
All Implemented Interfaces:
Map<String,Object>

public class SearchRequestMap extends Object implements Map<String,Object>
A custom implementation of Map that provides access to the properties of a SearchRequest's SearchSourceBuilder. The class allows retrieving and modifying specific properties of the search request.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K extends Object,V extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new instance of the SearchRequestMap with the provided SearchRequest.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all properties from the SearchSourceBuilder.
    compute(String key, BiFunction<? super String,? super Object,?> remappingFunction)
    If the value for the specified property is present, attempts to compute a new mapping given the property and its current mapped value, or removes the property if the computed value is null.
    computeIfAbsent(String key, Function<? super String,?> mappingFunction)
    The computed value associated with the property, or null if the property is not present.
    computeIfPresent(String key, BiFunction<? super String,? super Object,?> remappingFunction)
    If the value for the specified property is present, attempts to compute a new mapping given the property and its current mapped value.
    boolean
    Checks if the SearchSourceBuilder contains the specified property.
    boolean
    Checks if the SearchSourceBuilder contains the specified value.
    Returns a set view of the properties in the SearchSourceBuilder.
    void
    forEach(BiConsumer<? super String,? super Object> action)
    Performs the given action for each property in the SearchSourceBuilder until all properties have been processed or the action throws an exception
    get(Object key)
    Retrieves the value associated with the specified property from the SearchSourceBuilder.
    getOrDefault(Object key, Object defaultValue)
    Returns the value to which the specified property has, or the defaultValue if the property is not present in the SearchSourceBuilder.
    boolean
    Checks if the SearchSourceBuilder is empty.
    Returns a set view of the property names in the SearchSourceBuilder.
    merge(String key, Object value, BiFunction<? super Object,? super Object,?> remappingFunction)
    If the specified property is not already associated with a value or is associated with null, associates it with the given non-null value.
    put(String key, Object value)
    Sets the value for the specified property in the SearchSourceBuilder.
    void
    putAll(Map<? extends String,?> m)
    Sets all the properties from the specified map to the SearchSourceBuilder.
    putIfAbsent(String key, Object value)
    If the specified property is not already associated with a value, associates it with the given value and returns null, else returns the current value.
    Removes the specified property from the SearchSourceBuilder.
    boolean
    remove(Object key, Object value)
    Removes the property only if it has the given value.
    replace(String key, Object value)
    Replaces the specified property only if it has the given value.
    boolean
    replace(String key, Object oldValue, Object newValue)
    Replaces the specified property only if it has the given value.
    void
    replaceAll(BiFunction<? super String,? super Object,?> function)
    Replaces each property's value with the result of invoking the given function on that property until all properties have been processed or the function throws an exception.
    int
    Retrieves the number of properties in the SearchSourceBuilder.
    Returns a collection view of the property values in the SearchSourceBuilder.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.util.Map

    equals, hashCode
  • Constructor Details

    • SearchRequestMap

      public SearchRequestMap(SearchRequest searchRequest)
      Constructs a new instance of the SearchRequestMap with the provided SearchRequest.
      Parameters:
      searchRequest - The SearchRequest containing the SearchSourceBuilder to be accessed.
  • Method Details

    • size

      public int size()
      Retrieves the number of properties in the SearchSourceBuilder.
      Specified by:
      size in interface Map<String,Object>
      Returns:
      The number of properties in the SearchSourceBuilder.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • isEmpty

      public boolean isEmpty()
      Checks if the SearchSourceBuilder is empty.
      Specified by:
      isEmpty in interface Map<String,Object>
      Returns:
      true if the SearchSourceBuilder is empty, false otherwise.
    • containsKey

      public boolean containsKey(Object key)
      Checks if the SearchSourceBuilder contains the specified property.
      Specified by:
      containsKey in interface Map<String,Object>
      Parameters:
      key - The property to check for.
      Returns:
      true if the SearchSourceBuilder contains the specified property, false otherwise.
    • containsValue

      public boolean containsValue(Object value)
      Checks if the SearchSourceBuilder contains the specified value.
      Specified by:
      containsValue in interface Map<String,Object>
      Parameters:
      value - The value to check for.
      Returns:
      true if the SearchSourceBuilder contains the specified value, false otherwise.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • get

      public Object get(Object key)
      Retrieves the value associated with the specified property from the SearchSourceBuilder.
      Specified by:
      get in interface Map<String,Object>
      Parameters:
      key - The SearchSourceBuilder property whose value is to be retrieved.
      Returns:
      The value associated with the specified property or null if the property has not been initialized.
      Throws:
      IllegalArgumentException - if the property name is not a String.
      SearchRequestMapProcessingException - if the property is not supported.
    • put

      public Object put(String key, Object value)
      Sets the value for the specified property in the SearchSourceBuilder.
      Specified by:
      put in interface Map<String,Object>
      Parameters:
      key - The property whose value is to be set.
      value - The value to be set for the specified property.
      Returns:
      The original value associated with the property, or null if none existed.
      Throws:
      IllegalArgumentException - if the property is not a String.
      SearchRequestMapProcessingException - if the property is not supported or an error occurs during the setting.
    • remove

      public Object remove(Object key)
      Removes the specified property from the SearchSourceBuilder.
      Specified by:
      remove in interface Map<String,Object>
      Parameters:
      key - The name of the property that will be removed.
      Returns:
      The value associated with the property before it was removed, or null if the property was not found.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • putAll

      public void putAll(Map<? extends String,?> m)
      Sets all the properties from the specified map to the SearchSourceBuilder.
      Specified by:
      putAll in interface Map<String,Object>
      Parameters:
      m - The map containing the properties to be set.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • clear

      public void clear()
      Removes all properties from the SearchSourceBuilder.
      Specified by:
      clear in interface Map<String,Object>
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • keySet

      public Set<String> keySet()
      Returns a set view of the property names in the SearchSourceBuilder.
      Specified by:
      keySet in interface Map<String,Object>
      Returns:
      A set view of the property names in the SearchSourceBuilder.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • values

      public Collection<Object> values()
      Returns a collection view of the property values in the SearchSourceBuilder.
      Specified by:
      values in interface Map<String,Object>
      Returns:
      A collection view of the property values in the SearchSourceBuilder.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Returns a set view of the properties in the SearchSourceBuilder.
      Specified by:
      entrySet in interface Map<String,Object>
      Returns:
      A set view of the properties in the SearchSourceBuilder.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • getOrDefault

      public Object getOrDefault(Object key, Object defaultValue)
      Returns the value to which the specified property has, or the defaultValue if the property is not present in the SearchSourceBuilder.
      Specified by:
      getOrDefault in interface Map<String,Object>
      Parameters:
      key - The property whose associated value is to be returned.
      defaultValue - The default value to be returned if the property is not present.
      Returns:
      The value to which the specified property has, or the defaultValue if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • forEach

      public void forEach(BiConsumer<? super String,? super Object> action)
      Performs the given action for each property in the SearchSourceBuilder until all properties have been processed or the action throws an exception
      Specified by:
      forEach in interface Map<String,Object>
      Parameters:
      action - The action to be performed for each property.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • replaceAll

      public void replaceAll(BiFunction<? super String,? super Object,?> function)
      Replaces each property's value with the result of invoking the given function on that property until all properties have been processed or the function throws an exception.
      Specified by:
      replaceAll in interface Map<String,Object>
      Parameters:
      function - The function to apply to each property.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • putIfAbsent

      public Object putIfAbsent(String key, Object value)
      If the specified property is not already associated with a value, associates it with the given value and returns null, else returns the current value.
      Specified by:
      putIfAbsent in interface Map<String,Object>
      Parameters:
      key - The property whose value is to be set if absent.
      value - The value to be associated with the specified property.
      Returns:
      The current value associated with the property, or null if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • remove

      public boolean remove(Object key, Object value)
      Removes the property only if it has the given value.
      Specified by:
      remove in interface Map<String,Object>
      Parameters:
      key - The property to be removed.
      value - The value expected to be associated with the property.
      Returns:
      true if the entry was removed, false otherwise.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • replace

      public boolean replace(String key, Object oldValue, Object newValue)
      Replaces the specified property only if it has the given value.
      Specified by:
      replace in interface Map<String,Object>
      Parameters:
      key - The property to be replaced.
      oldValue - The value expected to be associated with the property.
      newValue - The value to be associated with the property.
      Returns:
      true if the property was replaced, false otherwise.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • replace

      public Object replace(String key, Object value)
      Replaces the specified property only if it has the given value.
      Specified by:
      replace in interface Map<String,Object>
      Parameters:
      key - The property to be replaced.
      value - The value to be associated with the property.
      Returns:
      The previous value associated with the property, or null if the property was not found.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • computeIfAbsent

      public Object computeIfAbsent(String key, Function<? super String,?> mappingFunction)
      The computed value associated with the property, or null if the property is not present.
      Specified by:
      computeIfAbsent in interface Map<String,Object>
      Parameters:
      key - The property whose value is to be computed if absent.
      mappingFunction - The function to compute a value based on the property.
      Returns:
      The computed value associated with the property, or null if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • computeIfPresent

      public Object computeIfPresent(String key, BiFunction<? super String,? super Object,?> remappingFunction)
      If the value for the specified property is present, attempts to compute a new mapping given the property and its current mapped value.
      Specified by:
      computeIfPresent in interface Map<String,Object>
      Parameters:
      key - The property for which the mapping is to be computed.
      remappingFunction - The function to compute a new mapping.
      Returns:
      The new value associated with the property, or null if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • compute

      public Object compute(String key, BiFunction<? super String,? super Object,?> remappingFunction)
      If the value for the specified property is present, attempts to compute a new mapping given the property and its current mapped value, or removes the property if the computed value is null.
      Specified by:
      compute in interface Map<String,Object>
      Parameters:
      key - The property for which the mapping is to be computed.
      remappingFunction - The function to compute a new mapping.
      Returns:
      The new value associated with the property, or null if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.
    • merge

      public Object merge(String key, Object value, BiFunction<? super Object,? super Object,?> remappingFunction)
      If the specified property is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of applying the given remapping function to the current and new values.
      Specified by:
      merge in interface Map<String,Object>
      Parameters:
      key - The property for which the mapping is to be merged.
      value - The non-null value to be merged with the existing value.
      remappingFunction - The function to merge the existing and new values.
      Returns:
      The new value associated with the property, or null if the property is not present.
      Throws:
      UnsupportedOperationException - always, as the method is not supported.