Package org.elasticsearch.common.io

Examples of org.elasticsearch.common.io.FastStringReader


        }

        List<AnalyzeResponse.AnalyzeToken> tokens = Lists.newArrayList();
        TokenStream stream = null;
        try {
            stream = analyzer.reusableTokenStream(field, new FastStringReader(request.text()));
            stream.reset();
            CharTermAttribute term = stream.addAttribute(CharTermAttribute.class);
            PositionIncrementAttribute posIncr = stream.addAttribute(PositionIncrementAttribute.class);
            OffsetAttribute offset = stream.addAttribute(OffsetAttribute.class);
            TypeAttribute type = stream.addAttribute(TypeAttribute.class);
View Full Code Here


    public void testPm() throws Exception {
        LuceneMorphology russianLuceneMorphology = new RussianLuceneMorphology();
        LuceneMorphology englishLuceneMorphology = new EnglishLuceneMorphology();

        MorphologyAnalyzer russianAnalyzer = new MorphologyAnalyzer(russianLuceneMorphology);
        TokenStream stream = russianAnalyzer.tokenStream("name", new FastStringReader("тест пм тест"));
        MorphologyFilter englishFilter = new MorphologyFilter(stream, englishLuceneMorphology);
        assertSimpleTSOutput(englishFilter, new String[] {"тест", "тесто", "", "тест", "тесто"});
    }
View Full Code Here

      if (HashedStringFieldType.hashCode(fieldValue) == termHash)
         return fieldValue; // you never know :)

      String ret = null;
      try {
         stream = fieldIndexAnalyzer.reusableTokenStream(indexFieldName, new FastStringReader(fieldValue));
         stream.reset();
         CharTermAttribute term = stream.addAttribute(CharTermAttribute.class);

         while (stream.incrementToken()) {
            ret = term.toString();
View Full Code Here

    public static String getRiverVersion() {
        String version = "Undefined";
        try {
            String properties = Streams.copyToStringFromClasspath("/org/elasticsearch/river/mongodb/es-build.properties");
            Properties props = new Properties();
            props.load(new FastStringReader(properties));
            String ver = props.getProperty("version", "undefined");
            String hash = props.getProperty("hash", "undefined");
            if (!"undefined".equals(hash)) {
                hash = hash.substring(0, 7);
            }
View Full Code Here

        return new JsonXContentGenerator(jsonFactory.createGenerator(writer));
    }

    @Override
    public XContentParser createParser(String content) throws IOException {
        return new JsonXContentParser(jsonFactory.createParser(new FastStringReader(content)));
    }
View Full Code Here

    private static final RandomBasedUUIDGenerator RANDOM_UUID_GENERATOR = new RandomBasedUUIDGenerator();
    private static final UUIDGenerator TIME_UUID_GENERATOR = new TimeBasedUUIDGenerator();

    public static void spaceify(int spaces, String from, StringBuilder to) throws Exception {
        try (BufferedReader reader = new BufferedReader(new FastStringReader(from))) {
            String line;
            while ((line = reader.readLine()) != null) {
                for (int i = 0; i < spaces; i++) {
                    to.append(' ');
                }
View Full Code Here

            List<String> rules = Analysis.getWordList(env, settings, "synonyms");
            StringBuilder sb = new StringBuilder();
            for (String line : rules) {
                sb.append(line).append(System.getProperty("line.separator"));
            }
            rulesReader = new FastStringReader(sb.toString());
        } else if (settings.get("synonyms_path") != null) {
            rulesReader = Analysis.getReaderFromFile(env, settings, "synonyms_path");
        } else {
            throw new ElasticsearchIllegalArgumentException("synonym requires either `synonyms` or `synonyms_path` to be configured");
        }
View Full Code Here

        } else {
            final Entry last = entries.get(entries.size() - 1);
            lastStartOffset = last.startOffset() + last.reader().length();
        }
        final int startOffset = lastStartOffset + 1; // +1 because we insert a space between tokens
        Entry entry = new Entry(name, new FastStringReader(text), startOffset, boost);
        entries.add(entry);
    }
View Full Code Here

public class PropertiesSettingsLoader implements SettingsLoader {

    @Override
    public Map<String, String> load(String source) throws IOException {
        Properties props = new Properties();
        FastStringReader reader = new FastStringReader(source);
        try {
            props.load(reader);
            Map<String, String> result = newHashMap();
            for (Map.Entry entry : props.entrySet()) {
                result.put((String) entry.getKey(), (String) entry.getValue());
View Full Code Here

                Document d = ir.document(docNum);
                IndexableField fields[] = d.getFields(fieldName);
                for (IndexableField field : fields) {
                    final String stringValue = field.stringValue();
                    if (stringValue != null) {
                        addTermFrequencies(new FastStringReader(stringValue), termFreqMap, fieldName);
                    }
                }
            } else {
                addTermFrequencies(termFreqMap, vector);
            }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.io.FastStringReader

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.