I'm using Search API and Search API ElasticSearch. I encounter a strange issue under the following circumstances:

1. Have existing working index
2. Remove server from the index, disabling and clearing the index
3. Add the server back to the index and reindex some content
4. Date fields supplied by ElasticSearch are not rendered properly in views showing the index

UNTIL

Clear caches, and the indexed dates get rendered properly in the views.

search_api_views will run views_invalidate_cache() whenever an index is updated and its fields are changed.

Adding a check for newly enabled indexes will fix this issue.

I think the fix belongs to search_api rather than search_api_elasticsearch since the issue could happen elsewhere down the line.

Comments

jannis created an issue. See original summary.

jannis’s picture

Here is a patch that checks if an index was newly enabled during the hook_search_api_index_update implementation.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

Thanks for reporting this issue and already providing a fix!
You're right, it seems we overlooked that when writing that hook implementation. The attached revision just cleans up coding standards and makes it, I think, a bit clearer. But generally the patch looked great already.
Please test if the new version still works for you and I'll commit it.

jannis’s picture

Just applied your patch to a fresh search_api and it applied cleanly, and properly cleared the views cache on newly enabled search indexes.

RTBC +1

jannis’s picture

Status: Needs review » Reviewed & tested by the community

  • drunken monkey committed 40d143f on 7.x-1.x authored by jannis
    Issue #2928769 by jannis, drunken monkey: Fixed Views cache not being...
drunken monkey’s picture

Version: 7.x-1.22 » 7.x-1.x-dev
Component: General code » Views integration
Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for testing!
Committed.
Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.