Skip to content

Commit

Permalink
Search by DocID instead of ID when deleting old documents
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hieu1-hoangtrung committed Dec 15, 2023
1 parent 613c418 commit 15e48ad
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/org/codelibs/fess/helper/IndexingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private void deleteOldDocuments(final SearchEngineClient searchEngineClient, fin
}
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])));
}
}

Expand All @@ -145,7 +144,7 @@ public long deleteDocumentByUrl(final SearchEngineClient searchEngineClient, fin
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) {
Expand Down

0 comments on commit 15e48ad

Please sign in to comment.