Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] is filter not working with numeric Scripted fields #6996

Closed
LDrago27 opened this issue Jun 10, 2024 · 3 comments · Fixed by #7022
Closed

[BUG] is filter not working with numeric Scripted fields #6996

LDrago27 opened this issue Jun 10, 2024 · 3 comments · Fixed by #7022
Assignees
Labels
bug Something isn't working v2.16.0

Comments

@LDrago27
Copy link
Collaborator

LDrago27 commented Jun 10, 2024

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
image

Clicking on the Visualization
image

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.

@LDrago27 LDrago27 added bug Something isn't working untriaged labels Jun 10, 2024
@LDrago27 LDrago27 changed the title [BUG] is Operator filter not working with numeric fields [BUG] is Operator filter not working with numeric Scripted fields Jun 11, 2024
@LDrago27 LDrago27 changed the title [BUG] is Operator filter not working with numeric Scripted fields [BUG] is filter not working with numeric Scripted fields Jun 11, 2024
@LDrago27 LDrago27 reopened this Jun 11, 2024
@abbyhu2000
Copy link
Member

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.

@abbyhu2000
Copy link
Member

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.
Screenshot 2024-06-11 at 3 22 51 PM

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
Screenshot 2024-06-11 at 3 26 19 PM

@abbyhu2000
Copy link
Member

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.

Screen.Recording.2024-06-11.at.3.45.20.PM.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.16.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants