Repository: opensearch-project/OpenSearch-Dashboards (TypeScript)

Issue:
[BUG] is filter not working with numeric Scripted fields 
**Describe the bug**
Adding filters for scripted numeric fields using `is` operator after clicking the **Add Filter** Button does not produce any result. However directly clicking on a visualization containing the required field adds the filter correctly. This behavior is observed across visualizations. (Tested the behavior in VisBuilder & Vertical bar Visualization)

**Payload sent while using the Add Filter button**
[PayloadAddFilter.json](https://github.com/user-attachments/files/15779561/PayloadAddFilter.json)
**Payload being sent while clicking on the visualization directly**
[PayloadVisualization.json](https://github.com/user-attachments/files/15779562/PayloadVisualization.json)

Upon analysis of Payloads, the following observation was found.
When using the Add Filter button, The value is being sent as string.
`"value": "66"`
While when we are using the visualization to filter it sends the 
`"value": 66`

This explains why we are not getting the expected results with the Add Filter option in case of numeric fields  since we are sending the value as string. 


**Expected behavior**
Add Filter should work with scripted numeric fields while using the is operator.

**OpenSearch Version**
3.0.0-snapshot 
**Dashboards Version**
3.0.0

**Plugins**

Please list all plugins currently enabled.

**Screenshots**

Using the Add filter 
![image](https://github.com/opensearch-project/OpenSearch-Dashboards/assets/38322563/1fc711fd-c6d1-448b-8594-15959681b38f)

Clicking on the Visualization 
![image](https://github.com/opensearch-project/OpenSearch-Dashboards/assets/38322563/bf696b57-c458-4416-a17a-765ad562f58f)


**Host/Environment (please complete the following information):**
 - OS: [e.g. iOS]


 - Browser and version [e.g. 22]
 

**Additional context**

Add any other context about the problem here.


Discussion: Was able to reproduce this bug. 

When we add a filter by clicking on one of the bar on the visualization, it will send the query value as number type, `"value": 66`; whhen we add a filter using `add filter` button from the filter bar, it will send the query value as string type, `"value": "66"`. 

The above flows are true for both numeric scripted field, and any numeric fields.

However, when we send a query containing a value of string type for other numeric fields, ex. for opensearch_dashboards_sample_data_ecommerce, when we add filter like `products.price: "66"`, it will still work correctly. But whenever we send a query containing a value of string type for numeric scripted fields, the filter does not work.
When we create a scripted field, if we set the type as number, add filter will not work since the filter bar treats the input as a string. 

However, if we created the same scripted field as a string type, add filter will work correctly. 
<img width="1225" alt="Screenshot 2024-06-11 at 3 22 51 PM" src="https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/66d63c1b-b725-4969-8fa1-f50d7fab11f2">

So add filter will not work for `actual_price`, but will work for `actual_price_string`. 

So i think we should probably modify the filter bar to solve this issue? Like after user choose the field, and if the field is numeric type, the value input textbox should convert the string into a number so scripted field can work properly? @kavilla @AMoo-Miki 
<img width="644" alt="Screenshot 2024-06-11 at 3 26 19 PM" src="https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/e162bfb3-e6aa-4f11-b2f8-9bf09b1b4e56">






For boolean scripted field, the filter bar detects the type as boolean, and it populates boolean values to send, so the filter bar is working properly for boolean scripted field. 


https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/d7cf4307-6877-4add-9be5-fecfc97dacc0





Fix (patch):
diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/value_input_type.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/value_input_type.tsx
index 9d7709a5f667..fd1743e96c12 100644
--- a/src/plugins/data/public/ui/filter_bar/filter_editor/value_input_type.tsx
+++ b/src/plugins/data/public/ui/filter_bar/filter_editor/value_input_type.tsx
@@ -79,7 +79,7 @@ class ValueInputTypeUI extends Component<Props> {
                 ? (value as BigInt).toString()
                 : value
             }
-            onChange={this.onChange}
+            onChange={this.onNumberChange}
             controlOnly={this.props.controlOnly}
             className={this.props.className}
           />
@@ -151,6 +151,17 @@ class ValueInputTypeUI extends Component<Props> {
     this.props.onChange(boolValue);
   };
 
+  private onNumberChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+    const params = event.target.value;
+    let numValue;
+    if (typeof params === 'string') {
+      numValue = parseFloat(params);
+    } else if (typeof params === 'bigint') {
+      numValue = (params as BigInt).toString();
+    }
+    this.props.onChange(numValue ?? params);
+  };
+
   private onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
     const params = event.target.value;
     this.props.onChange(params);