Package org.apache.lucene.util

Examples of org.apache.lucene.util.CharsRefBuilder


        private final CharsRefBuilder spare;

        protected GeoPointEnum(BytesRefIterator termsEnum) {
            this.termsEnum = termsEnum;
            next = new GeoPoint();
            spare = new CharsRefBuilder();
        }
View Full Code Here


    }

    public Result getCorrections(Analyzer analyzer, BytesRef query, CandidateGenerator generator,
            float maxErrors, int numCorrections, IndexReader reader, String analysisField, WordScorer scorer, float confidence, int gramSize) throws IOException {
      
        return getCorrections(tokenStream(analyzer, query, new CharsRefBuilder(), analysisField), generator, maxErrors, numCorrections, reader, scorer, new BytesRef(" "), confidence, gramSize);

    }
View Full Code Here

        context.queryResult().suggest(execute(suggest, context.searcher().getIndexReader()));
    }

    public Suggest execute(SuggestionSearchContext suggest, IndexReader reader) {
        try {
            CharsRefBuilder spare = new CharsRefBuilder();
            final List<Suggestion<? extends Entry<? extends Option>>> suggestions = new ArrayList<>(suggest.suggestions().size());

            for (Map.Entry<String, SuggestionSearchContext.SuggestionContext> entry : suggest.suggestions().entrySet()) {
                SuggestionSearchContext.SuggestionContext suggestion = entry.getValue();
                Suggester<SuggestionContext> suggester = suggestion.getSuggester();
View Full Code Here

        if (length() == 0) {
            return "";
        }

        byte[] bytes = toBytes();
        final CharsRefBuilder ref = new CharsRefBuilder();
        ref.copyUTF8Bytes(bytes, offset, length);
        return ref.toString();
    }
View Full Code Here

    }

    private static String termsToString(Terms terms) throws IOException {
        String strings = "";
        TermsEnum termsEnum = terms.iterator(null);
        CharsRefBuilder spare = new CharsRefBuilder();
        BytesRef text;
        while((text = termsEnum.next()) != null) {
            spare.copyUTF8Bytes(text);
            String term = spare.toString();
            strings += term;
        }
        return strings;
    }
View Full Code Here

        builder.field(FieldStrings.FOUND, isExists());
        if (!isExists()) {
            return builder;
        }
        builder.startObject(FieldStrings.TERM_VECTORS);
        final CharsRefBuilder spare = new CharsRefBuilder();
        Fields theFields = getFields();
        Iterator<String> fieldIter = theFields.iterator();
        while (fieldIter.hasNext()) {
            buildField(builder, spare, theFields, fieldIter);
        }
View Full Code Here

        BytesRef bytesRef = new BytesRef(sb);
        return Base64.encodeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length, Base64.URL_SAFE);
    }

    public static ParsedScrollId parseScrollId(String scrollId) {
        CharsRefBuilder spare = new CharsRefBuilder();
        try {
            byte[] decode = Base64.decode(scrollId, Base64.URL_SAFE);
            spare.copyUTF8Bytes(decode, 0, decode.length);
        } catch (Exception e) {
            throw new ElasticsearchIllegalArgumentException("Failed to decode scrollId", e);
        }
        String[] elements = Strings.splitStringToArray(spare.get(), ';');
        if (elements.length < 2) {
            throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "]");
        }

        int index = 0;
View Full Code Here

     * @param termFreqMap a Map of terms and their frequencies
     * @param vector List of terms and their frequencies for a doc/field
     */
    private void addTermFrequencies(Map<String, Int> termFreqMap, Terms vector) throws IOException {
        final TermsEnum termsEnum = vector.iterator(null);
        final CharsRefBuilder spare = new CharsRefBuilder();
        BytesRef text;
        while((text = termsEnum.next()) != null) {
            spare.copyUTF8Bytes(text);
            final String term = spare.toString();
            if (isNoiseWord(term)) {
                continue;
            }

            DocsEnum docs = termsEnum.docs(null, null);
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.CharsRefBuilder

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.