Closed LDrago27 closed 2 months ago
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.
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
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.
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 Payload being sent while clicking on the visualization directly 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
Clicking on the Visualization
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.