Skip to content

Commit ef76db0

Browse files
committed
close categorizer if constructing analyzer fails
1 parent 6bbd203 commit ef76db0

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/CategorizeRawBlockHash.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.elasticsearch.compute.data.Page;
1919
import org.elasticsearch.core.Releasable;
2020
import org.elasticsearch.core.Releasables;
21-
import org.elasticsearch.index.IndexService;
2221
import org.elasticsearch.index.analysis.AnalysisRegistry;
2322
import org.elasticsearch.xpack.core.ml.job.config.CategorizationAnalyzerConfig;
2423
import org.elasticsearch.xpack.ml.aggs.categorization.TokenListCategorizer;
@@ -45,18 +44,9 @@ public class CategorizeRawBlockHash extends AbstractCategorizeBlockHash {
4544

4645
CategorizationAnalyzer analyzer;
4746
try {
48-
analyzer = new CategorizationAnalyzer(
49-
analysisRegistry.buildCustomAnalyzer(
50-
IndexService.IndexCreationContext.RELOAD_ANALYZERS,
51-
null,
52-
false,
53-
ANALYZER_CONFIG.getTokenizer(),
54-
ANALYZER_CONFIG.getCharFilters(),
55-
ANALYZER_CONFIG.getTokenFilters()
56-
),
57-
true
58-
);
47+
analyzer = new CategorizationAnalyzer(analysisRegistry, ANALYZER_CONFIG);
5948
} catch (IOException e) {
49+
categorizer.close();
6050
throw new RuntimeException(e);
6151
}
6252

0 commit comments

Comments
 (0)