|
22 | 22 | import com.carrotsearch.randomizedtesting.annotations.Timeout;
|
23 | 23 | import org.apache.lucene.index.DocValuesType;
|
24 | 24 | import org.apache.lucene.index.IndexableField;
|
| 25 | +import org.elasticsearch.action.index.IndexRequest; |
| 26 | +import org.elasticsearch.action.index.IndexResponse; |
25 | 27 | import org.elasticsearch.common.Strings;
|
26 | 28 | import org.elasticsearch.common.bytes.BytesReference;
|
27 | 29 | import org.elasticsearch.common.compress.CompressedXContent;
|
|
32 | 34 | import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
|
33 | 35 | import org.elasticsearch.index.mapper.NumberFieldTypeTests.OutOfRangeSpec;
|
34 | 36 | import org.elasticsearch.index.termvectors.TermVectorsService;
|
| 37 | +import org.elasticsearch.rest.RestStatus; |
35 | 38 |
|
36 | 39 | import java.io.ByteArrayInputStream;
|
37 | 40 | import java.io.IOException;
|
@@ -453,6 +456,23 @@ public void testOutOfRangeValues() throws IOException {
|
453 | 456 | parseRequest(NumberType.LONG, createIndexRequest("-9223372036854775808.9"));
|
454 | 457 | }
|
455 | 458 |
|
| 459 | + public void testLongIndexingOutOfRange() throws Exception { |
| 460 | + String mapping = Strings.toString(XContentFactory.jsonBuilder() |
| 461 | + .startObject().startObject("_doc") |
| 462 | + .startObject("properties") |
| 463 | + .startObject("number") |
| 464 | + .field("type", "long") |
| 465 | + .field("ignore_malformed", true) |
| 466 | + .endObject().endObject() |
| 467 | + .endObject().endObject()); |
| 468 | + createIndex("test57287"); |
| 469 | + client().admin().indices().preparePutMapping("test57287") |
| 470 | + .setType("_doc").setSource(mapping, XContentType.JSON).get(); |
| 471 | + String doc = "{\"number\" : 9223372036854775808}"; |
| 472 | + IndexResponse response = client().index(new IndexRequest("test57287").source(doc, XContentType.JSON)).get(); |
| 473 | + assertTrue(response.status() == RestStatus.CREATED); |
| 474 | + } |
| 475 | + |
456 | 476 | private void parseRequest(NumberType type, BytesReference content) throws IOException {
|
457 | 477 | createDocumentMapper(type).parse(new SourceToParse("test", "type", "1", content, XContentType.JSON));
|
458 | 478 | }
|
|
0 commit comments