Class SearchRequestMap
java.lang.Object
org.opensearch.search.pipeline.common.helpers.SearchRequestMap
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
-
Constructor Summary
ConstructorsConstructorDescriptionSearchRequestMap(SearchRequest searchRequest) Constructs a new instance of theSearchRequestMapwith the providedSearchRequest. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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.booleancontainsKey(Object key) Checks if the SearchSourceBuilder contains the specified property.booleancontainsValue(Object value) Checks if the SearchSourceBuilder contains the specified value.entrySet()Returns a set view of the properties in the SearchSourceBuilder.voidforEach(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 exceptionRetrieves 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.booleanisEmpty()Checks if the SearchSourceBuilder is empty.keySet()Returns a set view of the property names in the SearchSourceBuilder.If the specified property is not already associated with a value or is associated with null, associates it with the given non-null value.Sets the value for the specified property in the SearchSourceBuilder.voidSets 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.booleanRemoves the property only if it has the given value.Replaces the specified property only if it has the given value.booleanReplaces the specified property only if it has the given value.voidreplaceAll(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.intsize()Retrieves the number of properties in the SearchSourceBuilder.values()Returns a collection view of the property values in the SearchSourceBuilder.
-
Constructor Details
-
SearchRequestMap
Constructs a new instance of theSearchRequestMapwith the providedSearchRequest.- 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:
sizein interfaceMap<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. -
containsKey
Checks if the SearchSourceBuilder contains the specified property.- Specified by:
containsKeyin interfaceMap<String,Object> - Parameters:
key- The property to check for.- Returns:
trueif the SearchSourceBuilder contains the specified property,falseotherwise.
-
containsValue
Checks if the SearchSourceBuilder contains the specified value.- Specified by:
containsValuein interfaceMap<String,Object> - Parameters:
value- The value to check for.- Returns:
trueif the SearchSourceBuilder contains the specified value,falseotherwise.- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
get
Retrieves the value associated with the specified property from the SearchSourceBuilder.- Specified by:
getin interfaceMap<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
Sets the value for the specified property in the SearchSourceBuilder.- Specified by:
putin interfaceMap<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
Removes the specified property from the SearchSourceBuilder.- Specified by:
removein interfaceMap<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
Sets all the properties from the specified map to the SearchSourceBuilder.- Specified by:
putAllin interfaceMap<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:
clearin interfaceMap<String,Object> - Throws:
UnsupportedOperationException- always, as the method is not supported.
-
keySet
Returns a set view of the property names in the SearchSourceBuilder.- Specified by:
keySetin interfaceMap<String,Object> - Returns:
- A set view of the property names in the SearchSourceBuilder.
- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
values
Returns a collection view of the property values in the SearchSourceBuilder.- Specified by:
valuesin interfaceMap<String,Object> - Returns:
- A collection view of the property values in the SearchSourceBuilder.
- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
entrySet
Returns a set view of the properties in the SearchSourceBuilder.- Specified by:
entrySetin interfaceMap<String,Object> - Returns:
- A set view of the properties in the SearchSourceBuilder.
- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
getOrDefault
Returns the value to which the specified property has, or the defaultValue if the property is not present in the SearchSourceBuilder.- Specified by:
getOrDefaultin interfaceMap<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
Performs the given action for each property in the SearchSourceBuilder until all properties have been processed or the action throws an exception- Specified by:
forEachin interfaceMap<String,Object> - Parameters:
action- The action to be performed for each property.- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
replaceAll
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:
replaceAllin interfaceMap<String,Object> - Parameters:
function- The function to apply to each property.- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
putIfAbsent
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:
putIfAbsentin interfaceMap<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
Removes the property only if it has the given value.- Specified by:
removein interfaceMap<String,Object> - Parameters:
key- The property to be removed.value- The value expected to be associated with the property.- Returns:
trueif the entry was removed,falseotherwise.- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
replace
Replaces the specified property only if it has the given value.- Specified by:
replacein interfaceMap<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:
trueif the property was replaced,falseotherwise.- Throws:
UnsupportedOperationException- always, as the method is not supported.
-
replace
Replaces the specified property only if it has the given value.- Specified by:
replacein interfaceMap<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
The computed value associated with the property, or null if the property is not present.- Specified by:
computeIfAbsentin interfaceMap<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:
computeIfPresentin interfaceMap<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
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:
computein interfaceMap<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:
mergein interfaceMap<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.
-