zhang created LUCENE-7227:
-----------------------------

             Summary:    TokenStream contract violation: reset()/close() call 
missing,
                 Key: LUCENE-7227
                 URL: https://issues.apache.org/jira/browse/LUCENE-7227
             Project: Lucene - Core
          Issue Type: Bug
          Components: core/queryparser
    Affects Versions: 6.0
            Reporter: zhang


    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. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to