Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.CachingTokenFilter.reset()


    CachingTokenFilter buffer = new CachingTokenFilter(source);
    TermToBytesRefAttribute termAtt = null;
    PositionIncrementAttribute posIncrAtt = null;
    int numTokens = 0;

    buffer.reset();

    if (buffer.hasAttribute(TermToBytesRefAttribute.class)) {
      termAtt = buffer.getAttribute(TermToBytesRefAttribute.class);
    }
    if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
View Full Code Here


        // ignore
      }
    }
    try {
      // rewind the buffer stream
      buffer.reset();

      // close original stream - all tokens buffered
      source.close();
    }
    catch (IOException e) {
View Full Code Here

        // ignore
      }

      try {
        // rewind the buffer stream
        buffer.reset();

        // close original stream - all tokens buffered
        source.close();
      } catch (IOException e) {
        // ignore
View Full Code Here

    CachingTokenFilter buffer = new CachingTokenFilter(source);
    TermToBytesRefAttribute termAtt = null;
    PositionIncrementAttribute posIncrAtt = null;
    int numTokens = 0;

    buffer.reset();

    if (buffer.hasAttribute(TermToBytesRefAttribute.class)) {
      termAtt = buffer.getAttribute(TermToBytesRefAttribute.class);
    }
    if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
View Full Code Here

        // ignore
      }
    }
    try {
      // rewind the buffer stream
      buffer.reset();

      // close original stream - all tokens buffered
      source.close();
    }
    catch (IOException e) {
View Full Code Here

      } finally {
        IOUtils.closeWhileHandlingException(source);
      }
     
      // rewind the buffer stream
      buffer.reset();

      if (!buffer.hasAttribute(CharTermAttribute.class)) {
        return new NoTokenFoundQueryNode();
      }
View Full Code Here

    // Assuming "<B>", "</B>" used to highlight
    SimpleHTMLFormatter formatter = new SimpleHTMLFormatter();
    Highlighter highlighter = new Highlighter(formatter, new SpanScorer(query, fieldName,
        tokenStream, FIELD_NAME));
    highlighter.setTextFragmenter(new SimpleFragmenter(Integer.MAX_VALUE));
    tokenStream.reset();
    String rv = highlighter.getBestFragments(tokenStream, text, 1, "(FIELD TEXT TRUNCATED)");
    return rv.length() == 0 ? text : rv;
  }

  public void testSimpleSpanHighlighter() throws Exception {
View Full Code Here

      String text = hits.doc(i).get(FIELD_NAME);
      CachingTokenFilter tokenStream = new CachingTokenFilter(analyzer.tokenStream(FIELD_NAME,
          new StringReader(text)));
      Highlighter highlighter = new Highlighter(new SpanScorer(query, FIELD_NAME, tokenStream));
      highlighter.setTextFragmenter(new SimpleFragmenter(40));
      tokenStream.reset();

      String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,
          "...");
      System.out.println("\t" + result);
    }
View Full Code Here

      CachingTokenFilter tokenStream = new CachingTokenFilter(analyzer.tokenStream(FIELD_NAME,
          new StringReader(text)));
      Highlighter highlighter = new Highlighter(this,
          new SpanScorer(query, FIELD_NAME, tokenStream));
      highlighter.setTextFragmenter(new SimpleFragmenter(40));
      tokenStream.reset();

      String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,
          "...");
      System.out.println("\t" + result);
    }
View Full Code Here

      CachingTokenFilter tokenStream = new CachingTokenFilter(analyzer.tokenStream(FIELD_NAME,
          new StringReader(text)));
      Highlighter highlighter = new Highlighter(this,
          new SpanScorer(query, FIELD_NAME, tokenStream));
      highlighter.setTextFragmenter(new SimpleFragmenter(40));
      tokenStream.reset();

      String result = highlighter.getBestFragments(tokenStream, text, maxNumFragmentsRequired,
          "...");
      System.out.println("\t" + result);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.