Package org.apache.lucene.analysis

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


      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

      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

      } else if (mode == SPAN) {
        CachingTokenFilter tokenStream = new CachingTokenFilter(stream);
        Highlighter highlighter;
        try {
          highlighter = new Highlighter(formatter, new SpanScorer(query, fieldName, tokenStream));
          tokenStream.reset();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }

        return highlighter;
View Full Code Here

      scorer.init(tokenStream);
     
            Highlighter highlighter =
                new Highlighter(new DomainSearchFormatter(), scorer);
            highlighter.setTextFragmenter(fragmenter);
            tokenStream.reset();

            try {
                return highlighter.getBestFragments(tokenStream, text, 2, " ... ");

            } catch (InvalidTokenOffsetsException 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

    PositionIncrementAttribute posIncrAtt = null;
    int numTokens = 0;

    boolean success = false;
    try {
      buffer.reset();
      success = true;
    } catch (IOException e) {
      // success==false if we hit an exception
    }
    if (success) {
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

    TokenStream source = null;
    try {
      source = analyzer.tokenStream(field, queryText);
      source.reset();
      buffer = new CachingTokenFilter(source);
      buffer.reset();

      if (buffer.hasAttribute(TermToBytesRefAttribute.class)) {
        termAtt = buffer.getAttribute(TermToBytesRefAttribute.class);
      }
      if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
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.