Search by DocID instead of ID when deleting old documents (#2787)

The method IndexingHelper#deleteOldDocuments() is responsible for removing
old search entries, and it seems that it can find these old entries correctly
(the docIdList correctly contains old entries).

But the deleteByQuery() call seems to be searching the wrong column (with the
default settings, it is searching by "_id" column instead of "doc_id").

This patch changes the QueryBuilder (used by deleteByQuery) from querying
by "_id" column to "doc_id" instead.
This commit is contained in:
Hoang Trung Hieu 2023-12-16 06:09:57 +07:00 committed by GitHub
parent 613c418631
commit 642d96a1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,8 +121,7 @@ public class IndexingHelper {
}
if (!docIdList.isEmpty()) {
searchEngineClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(),
QueryBuilders.idsQuery().addIds(docIdList.stream().toArray(n -> new String[n])));
QueryBuilders.termsQuery(fessConfig.getIndexFieldDocId(), docIdList.stream().toArray(n -> new String[n])));
}
}
@ -145,7 +144,7 @@ public class IndexingHelper {
public long deleteDocumentsByDocId(final SearchEngineClient searchEngineClient, final List<String> docIdList) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
return searchEngineClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(),
QueryBuilders.idsQuery().addIds(docIdList.stream().toArray(n -> new String[n])));
QueryBuilders.termsQuery(fessConfig.getIndexFieldDocId(), docIdList.stream().toArray(n -> new String[n])));
}
public long deleteDocumentByQuery(final SearchEngineClient searchEngineClient, final QueryBuilder queryBuilder) {