Package org.elasticsearch.common

Examples of org.elasticsearch.common.BytesHolder


        searchResult.release();

        // but, we can still get it (in realtime)
        Engine.GetResult getResult = engine.get(new Engine.Get(true, newUid("1")));
        assertThat(getResult.exists(), equalTo(true));
        assertThat(getResult.source(), equalTo(new BytesHolder(B_1)));
        assertThat(getResult.docIdAndVersion(), nullValue());

        // but, not there non realtime
        getResult = engine.get(new Engine.Get(false, newUid("1")));
        assertThat(getResult.exists(), equalTo(false));

        // refresh and it should be there
        engine.refresh(new Engine.Refresh(true));

        // now its there...
        searchResult = engine.searcher();
        assertThat(searchResult, engineSearcherTotalHits(1));
        assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1));
        searchResult.release();

        // also in non realtime
        getResult = engine.get(new Engine.Get(false, newUid("1")));
        assertThat(getResult.exists(), equalTo(true));
        assertThat(getResult.docIdAndVersion(), notNullValue());

        // now do an update
        doc = new ParsedDocument("1", "1", "test", null, doc().add(uidField("1")).add(field("value", "test1")).add(field(SourceFieldMapper.NAME, B_2, Field.Store.YES)).build(), Lucene.STANDARD_ANALYZER, B_2, false);
        engine.index(new Engine.Index(null, newUid("1"), doc));

        // its not updated yet...
        searchResult = engine.searcher();
        assertThat(searchResult, engineSearcherTotalHits(1));
        assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test")), 1));
        assertThat(searchResult, engineSearcherTotalHits(new TermQuery(new Term("value", "test1")), 0));
        searchResult.release();

        // but, we can still get it (in realtime)
        getResult = engine.get(new Engine.Get(true, newUid("1")));
        assertThat(getResult.exists(), equalTo(true));
        assertThat(getResult.source(), equalTo(new BytesHolder(B_2)));
        assertThat(getResult.docIdAndVersion(), nullValue());

        // refresh and it should be updated
        engine.refresh(new Engine.Refresh(true));
View Full Code Here


            id = in.readUTF();
            type = in.readUTF();

            int length = in.readVInt();
            int offset = in.position();
            return new BytesHolder(in.underlyingBuffer(), offset, length);
        }
View Full Code Here

                        return new GetResult(true, versionValue.version(), null);
                    }
                    byte[] data = translog.read(versionValue.translogLocation());
                    if (data != null) {
                        try {
                            BytesHolder source = TranslogStreams.readSource(data);
                            return new GetResult(true, versionValue.version(), source);
                        } catch (IOException e) {
                            // switched on us, read it from the reader
                        }
                    }
View Full Code Here

            id = in.readUTF();
            type = in.readUTF();

            int length = in.readVInt();
            int offset = in.position();
            return new BytesHolder(in.underlyingBuffer(), offset, length);
        }
View Full Code Here

     */
    public BytesHolder sourceRef() {
        if (LZF.isCompressed(source.bytes(), source.offset(), source.length())) {
            try {
                // TODO decompress without doing an extra copy!
                this.source = new BytesHolder(LZFDecoder.decode(source.copyBytes()));
            } catch (IOException e) {
                throw new ElasticSearchParseException("failed to decompress source", e);
            }
        }
        return this.source;
View Full Code Here

     */
    public String sourceAsString() {
        if (source == null) {
            return null;
        }
        BytesHolder source = sourceRef();
        return Unicode.fromBytes(source.bytes(), source.offset(), source.length());
    }
View Full Code Here

                            }
                        }
                    }
                }

                return new GetResponse(index, type, id, get.version(), get.exists(), source == null ? null : new BytesHolder(source), fields);
            } else {
                BytesHolder source = get.source();

                Map<String, GetField> fields = null;
                boolean sourceRequested = false;

                // we can only load scripts that can run against the source
                if (gFields == null) {
                    sourceRequested = true;
                } else if (gFields.length == 0) {
                    // no fields, and no source
                    sourceRequested = false;
                } else {
                    Map<String, Object> sourceAsMap = SourceLookup.sourceAsMap(source.bytes(), source.offset(), source.length());
                    SearchLookup searchLookup = null;
                    for (String field : gFields) {
                        if (field.equals("_source")) {
                            sourceRequested = true;
                            continue;
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.BytesHolder

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.