From 013bed0a0a2dbfb6547421c7cc901aa57bf29d69 Mon Sep 17 00:00:00 2001 From: Rishabh Maurya Date: Fri, 19 Apr 2024 12:30:11 -0700 Subject: [PATCH] Fix the flaky test for derived fields highlighter test Signed-off-by: Rishabh Maurya --- .../DerivedFieldFetchAndHighlightTests.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java index 28d97c74d9445..92127da9654aa 100644 --- a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java +++ b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java @@ -144,17 +144,17 @@ public void testDerivedFieldFromIndexMapping() throws IOException { // create a fetch context to be used by HighlightPhase processor FetchContext fetchContext = mock(FetchContext.class); - when(fetchContext.mapperService()).thenReturn(mockShardContext.getMapperService()); + when(fetchContext.mapperService()).thenReturn(mapperService); when(fetchContext.getQueryShardContext()).thenReturn(mockShardContext); when(fetchContext.getIndexSettings()).thenReturn(indexService.getIndexSettings()); when(fetchContext.searcher()).thenReturn( new ContextIndexSearcher( - searcher.getIndexReader(), - searcher.getSimilarity(), - searcher.getQueryCache(), - searcher.getQueryCachingPolicy(), + reader, + IndexSearcher.getDefaultSimilarity(), + IndexSearcher.getDefaultQueryCache(), + IndexSearcher.getDefaultQueryCachingPolicy(), true, - searcher.getExecutor(), + null, null ) ); @@ -253,17 +253,17 @@ public void testDerivedFieldFromSearchMapping() throws IOException { // create a fetch context to be used by HighlightPhase processor FetchContext fetchContext = mock(FetchContext.class); - when(fetchContext.mapperService()).thenReturn(mockShardContext.getMapperService()); + when(fetchContext.mapperService()).thenReturn(mapperService); when(fetchContext.getQueryShardContext()).thenReturn(mockShardContext); when(fetchContext.getIndexSettings()).thenReturn(indexService.getIndexSettings()); when(fetchContext.searcher()).thenReturn( new ContextIndexSearcher( - searcher.getIndexReader(), - searcher.getSimilarity(), - searcher.getQueryCache(), - searcher.getQueryCachingPolicy(), + reader, + IndexSearcher.getDefaultSimilarity(), + IndexSearcher.getDefaultQueryCache(), + IndexSearcher.getDefaultQueryCachingPolicy(), true, - searcher.getExecutor(), + null, null ) );