How to check that index pattern is not synced with mapping using kibana plugin?

I'm trying to create kibana plugin that refreshes kibana index-pattern. Instead of doing it periodically.
Is there any way we can check after user has loaded the discover or visualize page, if the selected index pattern needs to be refreshed without comparing the mapping with the cached fields?
Or will I need to compare the output of /api/index_patterns/_fields_for_wildcard?pattern=test and existing field and refresh if needed?

kibana version - 6.4.2

Hello @Riddhesh

Is there any way we can check after user has loaded the discover or visualize page, if the selected index pattern needs to be refreshed without comparing the mapping with the cached fields?

Unfortunately there is not. We've discussed this flaw in index patterns as it can be considerably annoying. It's important to find a solution that doesn't negatively impact another set of users.

That said, I wholeheartedly encourage you to work on this and I'd like to see your results. Do not hesitate to reach out to me.

1 Like

Hi @mattkime, Is there any way we can access all indexpatterns from the cache from kibana plugin? I know there is cache when we get indexPatternService as $injector.get('indexPatterns');. But it only has get(id) method, and I'm trying to get by title. Please let me know if there is any way get all index-patterns that are already fetched.

Apologies for the delay in my reply. You would need to use the SavedObjectClient to query for index patterns. This is a known deficiency of the existing API. Let me know if you need info about the SavedObjectClient. Apologies for the terseness but I already delayed responding to this.