public void testPercolatorFieldMapper_noQuery() throws Exception {
    addQueryMapping();
    ParsedDocument doc =
        mapperService
            .documentMapper(typeName)
            .parse(
                "test",
                typeName,
                "1",
                XContentFactory.jsonBuilder().startObject().endObject().bytes());
    assertThat(doc.rootDoc().getFields(fieldType.getQueryBuilderFieldName()).length, equalTo(0));

    try {
      mapperService
          .documentMapper(typeName)
          .parse(
              "test",
              typeName,
              "1",
              XContentFactory.jsonBuilder().startObject().nullField(fieldName).endObject().bytes());
    } catch (MapperParsingException e) {
      assertThat(
          e.getDetailedMessage(), containsString("query malformed, must start with start_object"));
    }
  }
  public void testDocValuesNotAllowed() throws IOException {
    String mapping =
        jsonBuilder()
            .startObject()
            .startObject("type")
            .startObject("_all")
            .field("doc_values", true)
            .endObject()
            .endObject()
            .endObject()
            .string();
    try {
      createIndex("test").mapperService().documentMapperParser().parse(mapping);
      fail();
    } catch (MapperParsingException e) {
      assertThat(
          e.getDetailedMessage(),
          containsString("[_all] is always tokenized and cannot have doc values"));
    }

    mapping =
        jsonBuilder()
            .startObject()
            .startObject("type")
            .startObject("_all")
            .startObject("fielddata")
            .field("format", "doc_values")
            .endObject()
            .endObject()
            .endObject()
            .endObject()
            .string();
    Settings legacySettings =
        Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
    try {
      createIndex("test_old", legacySettings).mapperService().documentMapperParser().parse(mapping);
      fail();
    } catch (MapperParsingException e) {
      assertThat(
          e.getDetailedMessage(),
          containsString("[_all] is always tokenized and cannot have doc values"));
    }
  }