elastic/elasticsearch

Add a checkCancelled public method to ContextIndexSearcher

クローズ

#121,349 opened on 2025/01/30

 (5 件のコメント) (0 件のリアクション) (0 人の担当者)Java (25,882 件のフォーク)batch import
:Search Foundations/Search>enhancementTeam:Search Foundationshelp wanted

Repository metrics

Stars
 (76,700 個のスター)
PR merge metrics
 (平均マージ 2d) (30d で 1,000 merged PRs)

説明

Description

The ContextIndexSearcher has some API to deal with cancelled tasks, see for example hasCancellations() below. Acting on cancelled tasks can be useful in ValueFetchers (which can be implemented by plugins via custom runtime fields), where resources can be released in such a case. Although the method hasCancellations() is public and accessible to plugins, there is however no access point to its counterpart checkCancelled() (see below): that method would be needed to check if the search's task got cancelled (and act upon it).

  • Would it be possible to add a public access method to checkCancelled(), in order to allow plugins to handle cancellations in custom runtime fields ?
  • Related question: are IndexSearchers used in Elasticsearch all ContextIndexSearcher instances ?

https://github.com/elastic/elasticsearch/blob/0d2db063ec4d8e95941e3b92dc150e294e5f0689/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java#L193

https://github.com/elastic/elasticsearch/blob/0d2db063ec4d8e95941e3b92dc150e294e5f0689/server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java#L118

https://github.com/elastic/elasticsearch/blob/0d2db063ec4d8e95941e3b92dc150e294e5f0689/server/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java#L594

コントリビューターガイド