Closed (fixed)
Project:
Search API OpenSearch
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2022 at 03:48 UTC
Updated:
27 Apr 2023 at 06:32 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kim.pepperAccording to the docs, you can only update field types _before_ any data is indexed.
I think the best we can do is catch this error and display a helpful message to the user.
Comment #3
kim.pepperSee https://opensearch.org/docs/latest/opensearch/rest-api/update-mapping/
Comment #4
kim.pepperWe might be able to use
\Drupal\search_api\Item\FieldInterface::setTypeLocked()to indicate the field type cannot be changed.Comment #5
acbramley commentedSo it is possible to change field mappings if you clear the index and re-index everything. The issue is that once you change a field mapping search_api adds a new task to the DB to update that mapping. Doing any other action on the index tries to execute that task first which results in an exception and doesn't delete the task. It means that it's impossible to clear the index after changing a field's type. The only workaround currently is to manually delete all tasks (e.g
delete from search_api_task;) and then clear the index. After doing that you're able to index again with the new field mapping.I wonder if we can simply hook into the updateMapping process and re-create the index first?
Comment #7
kim.pepperAdd a reindex() call when updating the mapping.
Comment #8
kim.pepperMarking for reindex isn't enough. We need to recreate in the index.
Comment #9
kim.pepperTesting a patch file.
Comment #10
acbramley commentedWorks for me!
Comment #12
kim.pepperCommitted and pushed to 1.x. Thanks!