Package org.elasticsearch.common.compress

Examples of org.elasticsearch.common.compress.CompressedString


    public void testDefaultTimestampStream() throws IOException {
        // Testing null value for default timestamp
        {
            MappingMetaData.Timestamp timestamp = new MappingMetaData.Timestamp(true, null,
                    TimestampFieldMapper.DEFAULT_DATE_TIME_FORMAT, null);
            MappingMetaData expected = new MappingMetaData("type", new CompressedString("{}".getBytes(UTF8)),
                    new MappingMetaData.Id(null), new MappingMetaData.Routing(false, null), timestamp, false);

            BytesStreamOutput out = new BytesStreamOutput();
            MappingMetaData.writeTo(expected, out);
            out.close();
            BytesReference bytes = out.bytes();

            MappingMetaData metaData = MappingMetaData.readFrom(new BytesStreamInput(bytes));

            assertThat(metaData, is(expected));
        }

        // Testing "now" value for default timestamp
        {
            MappingMetaData.Timestamp timestamp = new MappingMetaData.Timestamp(true, null,
                    TimestampFieldMapper.DEFAULT_DATE_TIME_FORMAT, "now");
            MappingMetaData expected = new MappingMetaData("type", new CompressedString("{}".getBytes(UTF8)),
                    new MappingMetaData.Id(null), new MappingMetaData.Routing(false, null), timestamp, false);

            BytesStreamOutput out = new BytesStreamOutput();
            MappingMetaData.writeTo(expected, out);
            out.close();
View Full Code Here


                .build();
        IndexService indexService = createIndex("test", settings);
        MapperService mapperService = indexService.mapperService();

        String mapping = copyToStringFromClasspath("/org/elasticsearch/index/query/mapping.json");
        mapperService.merge("person", new CompressedString(mapping), true);
        mapperService.documentMapper("person").parse(new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/query/data.json")));

        queryParser = indexService.queryParserService();
    }
View Full Code Here

public class MappingMetaDataParserTests extends ElasticsearchTestCase {

    @Test
    public void testParseIdAlone() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .field("id", "id").field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
View Full Code Here

        assertThat(parseContext.timestampResolved(), equalTo(false));
    }
   
    @Test
    public void testFailIfIdIsNoValue() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .startArray("id").value("id").endArray().field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
View Full Code Here

        }
    }

    @Test
    public void testParseRoutingAlone() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .field("id", "id").field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
View Full Code Here

        assertThat(parseContext.timestampResolved(), equalTo(false));
    }

    @Test
    public void testParseTimestampAlone() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .field("id", "id").field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
View Full Code Here

        assertThat(parseContext.timestampResolved(), equalTo(true));
    }

    @Test
    public void testParseTimestampEquals() throws Exception {
        MappingMetaData md1 = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        MappingMetaData md2 = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        assertThat(md1, equalTo(md2));
    }
View Full Code Here

        assertThat(md1, equalTo(md2));
    }

    @Test
    public void testParseIdAndRoutingAndTimestamp() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("id"),
                new MappingMetaData.Routing(true, "routing"),
                new MappingMetaData.Timestamp(true, "timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .field("id", "id").field("routing", "routing_value").field("timestamp", "1").endObject().bytes().toBytes();
View Full Code Here

        assertThat(parseContext.timestamp(), equalTo("1"));
    }

    @Test
    public void testParseIdAndRoutingAndTimestampWithPath() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("obj1.id"),
                new MappingMetaData.Routing(true, "obj1.routing"),
                new MappingMetaData.Timestamp(true, "obj2.timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .startObject("obj0").field("field1", "value1").field("field2", "value2").endObject()
View Full Code Here

        assertThat(parseContext.timestamp(), equalTo("1"));
    }

    @Test
    public void testParseIdWithPath() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""),
                new MappingMetaData.Id("obj1.id"),
                new MappingMetaData.Routing(true, "obj1.routing"),
                new MappingMetaData.Timestamp(true, "obj2.timestamp", "dateOptionalTime", TimestampFieldMapper.Defaults.DEFAULT_TIMESTAMP), false);
        byte[] bytes = jsonBuilder().startObject().field("field1", "value1").field("field2", "value2")
                .startObject("obj0").field("field1", "value1").field("field2", "value2").endObject()
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.compress.CompressedString

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.