From a05fabd71ca95b9586c7ad7b02dc2375ef1def49 Mon Sep 17 00:00:00 2001 From: kyle-sammons Date: Mon, 30 Sep 2024 17:06:58 -0700 Subject: [PATCH] Move up to be class level --- .../com/slack/astra/logstore/search/SearchResultUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/astra/src/main/java/com/slack/astra/logstore/search/SearchResultUtils.java b/astra/src/main/java/com/slack/astra/logstore/search/SearchResultUtils.java index 80de17647b..78d29d03fb 100644 --- a/astra/src/main/java/com/slack/astra/logstore/search/SearchResultUtils.java +++ b/astra/src/main/java/com/slack/astra/logstore/search/SearchResultUtils.java @@ -46,6 +46,9 @@ public class SearchResultUtils { private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final SearchModule searchModule = new SearchModule(Settings.EMPTY, List.of()); + private static final NamedXContentRegistry namedXContentRegistry = + new NamedXContentRegistry(searchModule.getNamedXContents()); public static Map fromValueStruct(AstraSearch.Struct struct) { Map returnMap = new HashMap<>(); @@ -669,9 +672,7 @@ public static AstraSearch.SearchRequest.SearchAggregation.FiltersAggregation toF public static SearchQuery fromSearchRequest(AstraSearch.SearchRequest searchRequest) { QueryBuilder queryBuilder = null; - SearchModule searchModule = new SearchModule(Settings.EMPTY, List.of()); - NamedXContentRegistry namedXContentRegistry = - new NamedXContentRegistry(searchModule.getNamedXContents()); + if (!searchRequest.getQuery().isEmpty()) { try { JsonXContentParser jsonXContentParser =