Package org.elasticsearch.common.bytes

Examples of org.elasticsearch.common.bytes.BytesArray


                                XContentBuilder builder = XContentFactory.jsonBuilder().map(parser.mapOrdered());
                                source = builder.bytes();
                            }
                        } else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
                            if ("source".equals(currentFieldName)) {
                                source = new BytesArray(parser.binaryValue());
                            }
                        } else if (token.isValue()) {
                            if ("queryCache".equals(currentFieldName) || "query_cache".equals(currentFieldName)) {
                                queryCache = parser.booleanValue();
                            }
View Full Code Here


            return null;
        }

        BytesReference bytes;
        if (value instanceof BytesRef) {
            bytes = new BytesArray((BytesRef) value);
        } else if (value instanceof BytesReference) {
            bytes = (BytesReference) value;
        } else if (value instanceof byte[]) {
            bytes = new BytesArray((byte[]) value);
        } else {
            try {
                bytes = new BytesArray(Base64.decode(value.toString()));
            } catch (IOException e) {
                throw new ElasticsearchParseException("failed to convert bytes", e);
            }
        }
        try {
View Full Code Here

        if (value == null) {
            return null;
        }
        BytesReference bValue;
        if (value instanceof BytesRef) {
            bValue = new BytesArray((BytesRef) value);
        } else {
            bValue = (BytesReference) value;
        }
        try {
            return CompressorFactory.uncompressIfNeeded(bValue).toBytes();
View Full Code Here

            return termBytes.utf8ToString();
        }

        @Override
        public Text getKeyAsText() {
            return new BytesText(new BytesArray(termBytes));
        }
View Full Code Here

    /**
     * The source to execute. It is preferable to use either {@link #source(byte[])}
     * or {@link #source(QuerySourceBuilder)}.
     */
    public DeleteByQueryRequest source(String query) {
        this.source = new BytesArray(query.getBytes(Charsets.UTF_8));
        this.sourceUnsafe = false;
        return this;
    }
View Full Code Here

    /**
     * The source to execute.
     */
    public DeleteByQueryRequest source(byte[] source, int offset, int length, boolean unsafe) {
        this.source = new BytesArray(source, offset, length);
        this.sourceUnsafe = unsafe;
        return this;
    }
View Full Code Here

        MapperService mapperService = indexService.mapperService();
        String mapping = copyToStringFromClasspath("/org/elasticsearch/index/query/mapping.json");
        mapperService.merge("person", new CompressedString(mapping), true);
        String childMapping = copyToStringFromClasspath("/org/elasticsearch/index/query/child-mapping.json");
        mapperService.merge("child", new CompressedString(childMapping), true);
        mapperService.documentMapper("person").parse(new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/query/data.json")));
        queryParser = injector.getInstance(IndexQueryParserService.class);
    }
View Full Code Here

        builder.endObject();
        return XContentHelper.convertToJson(builder.bytes(), false);
    }

    private MultiGetRequest.Item JSONtoItem(String json) throws Exception {
        MultiGetRequest request = new MultiGetRequest().add(null, null, null, null, new BytesArray(json), true);
        return request.getItems().get(0);
    }
View Full Code Here

        }
    }

    private List<MultiGetRequest.Item> testItemsFromJSON(String json) throws Exception {
        MultiGetRequest request = new MultiGetRequest();
        request.add(null, null, null, null, new BytesArray(json), true);
        List<MultiGetRequest.Item> items = request.getItems();

        assertEquals(items.size(), 3);
        for (MultiGetRequest.Item item : items) {
            assertThat(item.index(), is("test"));
View Full Code Here

        for (Token token : tokens) {
            // TODO: Extend DirectSpellChecker in 4.1, to get the raw suggested words as BytesRef
            SuggestWord[] suggestedWords = directSpellChecker.suggestSimilar(
                    token.term, suggestion.getShardSize(), indexReader, suggestion.getDirectSpellCheckerSettings().suggestMode()
            );
            Text key = new BytesText(new BytesArray(token.term.bytes()));
            TermSuggestion.Entry resultEntry = new TermSuggestion.Entry(key, token.startOffset, token.endOffset - token.startOffset);
            for (SuggestWord suggestWord : suggestedWords) {
                Text word = new StringText(suggestWord.string);
                resultEntry.addOption(new TermSuggestion.Entry.Option(word, suggestWord.freq, suggestWord.score));
            }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.bytes.BytesArray

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.