Package org.elasticsearch.index.mapper

Examples of org.elasticsearch.index.mapper.ParsedDocument


                doc = doc.field(fieldName, s);
            }

            doc = doc.endObject();

            final ParsedDocument d = mapper.parse("type", Integer.toString(i), doc.bytes());

            writer.addDocument(d.rootDoc());

            if (random.nextInt(10) == 0) {
                refreshReader();
            }
        }
View Full Code Here


                }
                doc = doc.endArray();
            }
            doc = doc.endObject();

            final ParsedDocument d = mapper.parse("type", Integer.toString(i), doc.bytes());

            writer.addDocument(d.rootDoc());
            if (random.nextInt(10) == 0) {
                refreshReader();
            }
        }
        LeafReaderContext context = refreshReader();
View Full Code Here

            for (int j = 0; j < numValues; ++j) {
                doc = doc.value(values[j]);
            }
            doc = doc.endArray().endObject();

            final ParsedDocument d = mapper.parse("type", Integer.toString(i), doc.bytes());

            writer.addDocument(d.rootDoc());
            if (random.nextInt(10) == 0) {
                refreshReader();
            }
        }
        LeafReaderContext context = refreshReader();
View Full Code Here

                } else {
                    doc.startObject().field("lat", randomDouble() * 180 - 90).field("lon", randomDouble() * 360 - 180).endObject();
                }
            }
            doc = doc.endArray().endObject();
            final ParsedDocument d = mapper.parse("type", Integer.toString(i), doc.bytes());

            writer.addDocument(d.rootDoc());
            if (random.nextInt(10) == 0) {
                refreshReader();
            }
        }
        LeafReaderContext context = refreshReader();
View Full Code Here

                .endObject()
                .endObject().endObject().string();

        DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);

        ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .field("field1", "value1")
                .field("field2", "value2")
                .bytes());

        assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
        assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(1.0d, 0.000001d));
        assertThat(doc.rootDoc().get("field2"), equalTo("value2"));

        doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .startObject("field1").field("value", "value1").field("boost", 2.0f).endObject()
                .field("field2", "value2")
                .bytes());

        assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
        assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(2.0d, 0.000001d));
        assertThat(doc.rootDoc().get("field2"), equalTo("value2"));

        doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .field("field1", "value1")
                .field("field2", "value2")
                .bytes());

        assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
        assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(1.0d, 0.000001d));
        assertThat(doc.rootDoc().get("field2"), equalTo("value2"));
    }
View Full Code Here

                .startObject("properties").startObject("ip").field("type", "ip").endObject().endObject()
                .endObject().endObject().string();

        DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);

        ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .field("ip", "127.0.0.1")
                .endObject()
                .bytes());

        assertThat(doc.rootDoc().getField("ip").numericValue().longValue(), is(2130706433L));
        assertThat(doc.rootDoc().get("ip"), is(nullValue()));
    }
View Full Code Here

        BytesReference source = XContentFactory.jsonBuilder()
                .startObject()
                .field("field", "value")
                .endObject()
                .bytes();
        ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").timestamp(1));

        assertThat(doc.rootDoc().getField("_timestamp"), equalTo(null));
    }
View Full Code Here

        BytesReference source = XContentFactory.jsonBuilder()
                .startObject()
                .field("field", "value")
                .endObject()
                .bytes();
        ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").timestamp(1));

        assertThat(doc.rootDoc().getField("_timestamp").fieldType().stored(), equalTo(true));
        assertNotSame(IndexOptions.NONE, doc.rootDoc().getField("_timestamp").fieldType().indexOptions());
        assertThat(doc.rootDoc().getField("_timestamp").tokenStream(docMapper.indexAnalyzer(), null), notNullValue());
    }
View Full Code Here

                .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject()
                .endObject().endObject().string();

        DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);

        ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .startObject("point").field("lat", 1.2).field("lon", 1.3).endObject()
                .endObject()
                .bytes());

        assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
        assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
        assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
    }
View Full Code Here

                .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).field("geohash", true).endObject().endObject()
                .endObject().endObject().string();

        DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);

        ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
                .startObject()
                .field("point", "1.2,1.3")
                .endObject()
                .bytes());

        assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
        assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
        assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3)));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.mapper.ParsedDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.