Open vzhgit opened 2 years ago
Having taken a look at whats causing this, it seems almost intentional given how the code for this is written.
This is happening because we create a hash table of all the fields and how many times they have occurred in the search result. The count however is not reset when the search is updated. This causes the field present in the initial search to persist.
To me this seems like a useful feature if the user is filtering an index pattern and wants to continue exploring the existing fields. Changing the indexpattern, updating the search bar etc still trigger the available fields to still update.
We could make it more evident that the field is not present in the current set of filtered documents instead of hiding them all together. @ahopp @kgcreative What are your thoughts on this?
@ashwin-pc - Sounds like the bug is that the available fields are not updated when filters are added. I would expect fields to dynamically update when Hide missing fields
is on. We can confirm this because a hard refresh does update the count.
@ashwin-pc @abbyhu2000 Do we have this same problem in VisBuilder? If not, and if we use the VisBuilder fields as a jumping-off point for de-angularizing discover, this may go away.
On VisBuilder the list of available fields is not dynamic. It does not represent all the available fields for the given search space, but rather all the available fields for the index in its mapping. A argument could be made whether we should hide missing fields there too, and I think we missed that during the initial implementation. Created an issue for that here https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3074.
As for your comment about using VisBuilder as a jump off point, I think we could do that because solving this problem there correctly could be used to solve the problem for discover too since the Available fields section was built to mimic discovers
Describe the bug
We are migrating to OpenSearch and found this strange behavior: List of Available fields on Discover page is not correctly refreshed after pressing "Refresh" button or applying a filter if "Hide missing fields" is turned on. But if refresh a browser's page (F5) the list will contain right list of fields.
To Reproduce Steps to reproduce the behavior:
Expected behavior after applying a filter (Step 4) list of available fields list must contains fields only from documents from the search result (Step 6)
OpenSearch Version
Dashboards Version 1.2.0
Plugins
Host/Environment (please complete the following information):