From 14420d7c4e15df9b565b50ef5beab797f756c3ac Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 23 May 2014 01:20:41 +0200 Subject: [PATCH] [TESTS] Fix test to use index-level doc IDs instead of segment-level doc IDs. --- .../elasticsearch/search/highlight/CustomHighlighter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java b/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java index e7f1959c5be..4f21601c669 100644 --- a/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java +++ b/src/test/java/org/elasticsearch/search/highlight/CustomHighlighter.java @@ -40,13 +40,14 @@ public class CustomHighlighter implements Highlighter { public HighlightField highlight(HighlighterContext highlighterContext) { SearchContextHighlight.Field field = highlighterContext.field; CacheEntry cacheEntry = (CacheEntry) highlighterContext.hitContext.cache().get("test-custom"); + final int docId = highlighterContext.hitContext.readerContext().docBase + highlighterContext.hitContext.docId(); if (cacheEntry == null) { cacheEntry = new CacheEntry(); highlighterContext.hitContext.cache().put("test-custom", cacheEntry); - cacheEntry.docId = highlighterContext.hitContext.docId(); + cacheEntry.docId = docId; cacheEntry.position = 1; } else { - if (cacheEntry.docId == highlighterContext.hitContext.docId()) { + if (cacheEntry.docId == docId) { cacheEntry.position++; } else { cacheEntry.docId = highlighterContext.hitContext.docId();