浏览代码

Tests: Fix bug in SimpleSortTests.

This tests adds a mappings with {"fielddata": {"format": "doc_values"}} but the
default mapping has {"doc_values": false} so when the document mapper parsing
logic merges both we have {"doc_values": false,"fielddata": {"format": "doc_values"}}
and {"doc_values": false} wins, so the test is not using doc values while it
thought it would.
Adrien Grand 10 年之前
父节点
当前提交
717dbb0599
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java

+ 4 - 3
src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java

@@ -1560,10 +1560,11 @@ public class SimpleSortTests extends ElasticsearchIntegrationTest {
     public void testSortMetaField() throws Exception {
     public void testSortMetaField() throws Exception {
         final boolean idDocValues = maybeDocValues();
         final boolean idDocValues = maybeDocValues();
         final boolean timestampDocValues = maybeDocValues();
         final boolean timestampDocValues = maybeDocValues();
+        XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
+                .startObject("_timestamp").field("enabled", true).field("store", true).field("index", !timestampDocValues || randomBoolean() ? "not_analyzed" : "no").field("doc_values", timestampDocValues).endObject()
+                .endObject().endObject();
         assertAcked(prepareCreate("test")
         assertAcked(prepareCreate("test")
-            .addMapping("type", XContentFactory.jsonBuilder().startObject().startObject("type")
-                        .startObject("_timestamp").field("enabled", true).field("store", true).field("index", !timestampDocValues || randomBoolean() ? "not_analyzed" : "no").startObject("fielddata").field("format", timestampDocValues ? "doc_values" : null).endObject().endObject()
-                        .endObject().endObject()));
+            .addMapping("type", mapping));
         ensureGreen();
         ensureGreen();
         final int numDocs = randomIntBetween(10, 20);
         final int numDocs = randomIntBetween(10, 20);
         IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs];
         IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs];