avoid reindexing secondary indexes after they succeed (#1971)

This commit is contained in:
rkuo-danswer 2024-07-29 20:12:58 -07:00 committed by GitHub
parent 96b582070b
commit 015f415b71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,20 +68,26 @@ def _should_create_new_indexing(
return False
# When switching over models, always index at least once
if model.status == IndexModelStatus.FUTURE and not last_index:
if connector.id == 0: # Ingestion API
return False
if model.status == IndexModelStatus.FUTURE:
if last_index:
# secondary indexes should not index again after success
# or else the model will never be able to swap
if last_index.status == IndexingStatus.SUCCESS:
return False
else:
if connector.id == 0: # Ingestion API
return False
return True
# If the connector is disabled, don't index
# NOTE: during an embedding model switch over, we ignore this
# and index the disabled connectors as well (which is why this if
# statement is below the first condition above)
# NOTE: during an embedding model switch over, the following logic
# is bypassed by the above check for a future model
if connector.disabled:
return False
if connector.refresh_freq is None:
return False
if not last_index:
return True