From 0688dddebff428df164b16ebff244f7ba3a5fe7b Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 14 Aug 2015 16:34:04 +0200 Subject: [PATCH] Also delegate rewrite the the wrapped IndexSearcher. In the the AssertingIndexSearcher is used we then also have extra validation when rewritting the query. --- .../search/internal/ContextIndexSearcher.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index e80d006ea72..11ce914fff3 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -63,6 +63,16 @@ public class ContextIndexSearcher extends IndexSearcher implements Releasable { this.dfSource = dfSource; } + @Override + public Query rewrite(Query original) throws IOException { + try { + return in.rewrite(original); + } catch (Throwable t) { + searchContext.clearReleasables(Lifetime.COLLECTION); + throw ExceptionsHelper.convertToElastic(t); + } + } + @Override public Weight createNormalizedWeight(Query query, boolean needsScores) throws IOException { try {