Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7227

TokenStream contract violation: reset()/close() call missing,

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 6.0
    • Fix Version/s: None
    • Component/s: core/queryparser
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      public static void highLightClojure(int id, String text, String field) {
      try {
      Query queryToSearch;
      TokenStream tokenStream = TokenSources.getTokenStream( field,text, analyzer);
      queryToSearch = new QueryParser("asddf", analyzer).parse("read text file string utf8");
      Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter(),
      new QueryScorer(queryToSearch));

      TextFragment[] frag = highlighter.getBestTextFragments(tokenStream, text, false, 4);
      for (int j = 0; j < frag.length; j++) {
      if ((frag[j] != null))

      { System.out.println("score: " + frag[j].getScore() + ", frag: " + (frag[j].toString())); }

      }
      } catch (IOException e)

      { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidTokenOffsetsException e) { // TODO Auto-generated catch block e.printStackTrace(); }

      catch (ParseException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      }

      Exception:
      TokenStream contract violation: reset()/close() call missing,
      reset() called multiple times, or subclass does not call
      super.reset(). Please see Javadocs of TokenStream class for more
      information about the correct consuming workflow.

      The tokenStream must be created after QueryParser, its an implicit dependency, but no any information mentioned it.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zhanglei Lei Zhang
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: