Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ private static Response prepareRamIndex(Request request,
String type = indexService.mapperService().documentMapper().type();
BytesReference document = request.contextSetup.document;
XContentType xContentType = request.contextSetup.xContentType;
SourceToParse sourceToParse = SourceToParse.source(index, type, "_id", document, xContentType);
SourceToParse sourceToParse = new SourceToParse(index, type, "_id", document, xContentType);
ParsedDocument parsedDocument = indexService.mapperService().documentMapper().parse(sourceToParse);
indexWriter.addDocuments(parsedDocument.docs());
try (IndexReader indexReader = DirectoryReader.open(indexWriter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testDefaults() throws Exception {
assertEquals(mapping, mapper.mappingSource().toString());

float[] expectedArray = {-12.1f, 100.7f, -4};
ParsedDocument doc1 = mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
ParsedDocument doc1 = mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("my-dense-vector").value(expectedArray[0]).value(expectedArray[1]).value(expectedArray[2]).endArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testDefaults() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc1 = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 10)
Expand All @@ -84,7 +84,7 @@ public void testDefaults() throws Exception {
assertThat(fields[0], Matchers.instanceOf(FeatureField.class));
FeatureField featureField1 = (FeatureField) fields[0];

ParsedDocument doc2 = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 12)
Expand All @@ -108,7 +108,7 @@ public void testNegativeScoreImpact() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc1 = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 10)
Expand All @@ -120,7 +120,7 @@ public void testNegativeScoreImpact() throws Exception {
assertThat(fields[0], Matchers.instanceOf(FeatureField.class));
FeatureField featureField1 = (FeatureField) fields[0];

ParsedDocument doc2 = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc2 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 12)
Expand All @@ -145,7 +145,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
assertEquals(mapping, mapper.mappingSource().toString());

MapperParsingException e = expectThrows(MapperParsingException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", Arrays.asList(10, 20))
Expand All @@ -155,7 +155,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
e.getCause().getMessage());

e = expectThrows(MapperParsingException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testDefaults() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc1 = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc1 = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("field")
Expand Down Expand Up @@ -95,7 +95,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
assertEquals(mapping, mapper.mappingSource().toString());

MapperParsingException e = expectThrows(MapperParsingException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("field")
Expand All @@ -107,7 +107,7 @@ public void testRejectMultiValuedFields() throws MapperParsingException, IOExcep
"START_ARRAY", e.getCause().getMessage());

e = expectThrows(MapperParsingException.class,
() -> mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
() -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startArray("foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testDefaults() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 123)
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testNotIndexed() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 123)
Expand All @@ -139,7 +139,7 @@ public void testNoDocValues() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 123)
Expand All @@ -163,7 +163,7 @@ public void testStore() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", 123)
Expand Down Expand Up @@ -192,7 +192,7 @@ public void testCoerce() throws Exception {

assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "123")
Expand All @@ -216,7 +216,7 @@ public void testCoerce() throws Exception {

assertEquals(mapping, mapper2.mappingSource().toString());

ThrowingRunnable runnable = () -> mapper2.parse(SourceToParse.source("test", "type", "1", BytesReference
ThrowingRunnable runnable = () -> mapper2.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", "123")
Expand Down Expand Up @@ -245,7 +245,7 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains

assertEquals(mapping, mapper.mappingSource().toString());

ThrowingRunnable runnable = () -> mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ThrowingRunnable runnable = () -> mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", value)
Expand All @@ -261,7 +261,7 @@ private void doTestIgnoreMalformed(String value, String exceptionMessageContains

DocumentMapper mapper2 = parser.parse("type", new CompressedXContent(mapping));

ParsedDocument doc = mapper2.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper2.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.field("field", value)
Expand All @@ -286,7 +286,7 @@ public void testNullValue() throws IOException {
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());

ParsedDocument doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
ParsedDocument doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.nullField("field")
Expand All @@ -308,7 +308,7 @@ public void testNullValue() throws IOException {
mapper = parser.parse("type", new CompressedXContent(mapping));
assertEquals(mapping, mapper.mappingSource().toString());

doc = mapper.parse(SourceToParse.source("test", "type", "1", BytesReference
doc = mapper.parse(new SourceToParse("test", "type", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.nullField("field")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
public void testDefaults() throws Exception {
int[] indexedDims = {65535, 50, 2};
float[] indexedValues = {0.5f, 1800f, -34567.11f};
ParsedDocument doc1 = mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
ParsedDocument doc1 = mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("my-sparse-vector")
Expand Down Expand Up @@ -103,7 +103,7 @@ public void testDefaults() throws Exception {
public void testErrors() {
// 1. test for an error on negative dimension
MapperParsingException e = expectThrows(MapperParsingException.class, () -> {
mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("my-sparse-vector")
Expand All @@ -118,7 +118,7 @@ public void testErrors() {

// 2. test for an error on a dimension greater than MAX_DIMS_NUMBER
e = expectThrows(MapperParsingException.class, () -> {
mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("my-sparse-vector")
Expand All @@ -133,7 +133,7 @@ public void testErrors() {

// 3. test for an error on a wrong formatted dimension
e = expectThrows(MapperParsingException.class, () -> {
mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("my-sparse-vector")
Expand All @@ -148,7 +148,7 @@ public void testErrors() {

// 4. test for an error on a wrong format for the map of dims to values
e = expectThrows(MapperParsingException.class, () -> {
mapper.parse(SourceToParse.source("test-index", "_doc", "1", BytesReference
mapper.parse(new SourceToParse("test-index", "_doc", "1", BytesReference
.bytes(XContentFactory.jsonBuilder()
.startObject()
.startObject("my-sparse-vector")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private SourceToParse createDocument(String fieldValue) throws Exception {
.field("test", fieldValue)
.endObject());

return SourceToParse.source("test", "person", "1", request, XContentType.JSON);
return new SourceToParse("test", "person", "1", request, XContentType.JSON);
}

private ParseContext.Document parseDocument(DocumentMapper mapper, SourceToParse request) {
Expand Down
Loading