Inner hits fail to propagate doc-value format. (#36310)

If you pass a doc-value format to inner hits, it gets ignored.
This commit is contained in:
Adrien Grand 2018-12-07 09:57:12 +01:00 committed by GitHub
parent 6a987415f8
commit 266b9bc796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -371,7 +371,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
if (docValueFields == null) {
docValueFields = new ArrayList<>();
}
docValueFields.add(new FieldAndFormat(field, null));
docValueFields.add(new FieldAndFormat(field, format));
return this;
}

View File

@ -46,6 +46,7 @@ import org.junit.BeforeClass;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -279,4 +280,12 @@ public class InnerHitBuilderTests extends ESTestCase {
return ESTestCase.copyWriteable(original, namedWriteableRegistry, InnerHitBuilder::new);
}
public void testSetDocValueFormat() {
InnerHitBuilder innerHit = new InnerHitBuilder();
innerHit.addDocValueField("foo");
innerHit.addDocValueField("@timestamp", "epoch_millis");
assertEquals(
Arrays.asList(new FieldAndFormat("foo", null), new FieldAndFormat("@timestamp", "epoch_millis")),
innerHit.getDocValueFields());
}
}