[ https://issues.apache.org/jira/browse/LUCENE-9128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17013924#comment-17013924 ]
Michael McCandless commented on LUCENE-9128: -------------------------------------------- You're welcome [~lingchao]! > Updating from 7.X to 8.X breaks due to change of TotalHits > ---------------------------------------------------------- > > Key: LUCENE-9128 > URL: https://issues.apache.org/jira/browse/LUCENE-9128 > Project: Lucene - Core > Issue Type: Bug > Reporter: xia0c > Priority: Major > > When I try to upgrade lucene-core from 7.X to version 8.X. The following code > breaks. > {code:java} > public class TestLucene { > > private IndexSearcher searcher; > public Analyzer analyzer; > > > public void demo(String keyword, int pageNum, int pageSize) throws > ParseException, IOException { > > String[] fields = {"title"}; > MultiFieldQueryParser multiFieldQueryParser = new > MultiFieldQueryParser(fields, analyzer); > Query query = multiFieldQueryParser.parse(keyword); > TopDocs topDocs = searcher.search(query, 100); > int start = (pageNum - 1) * pageSize; > int end = (int) Math.min(start + pageSize,topDocs.totalHits); > > } > } > {code} > The code should pass, but it throws an error: > {code:java} > [ERROR] /TestLucene.java:[26,29] no suitable method found for > min(int,org.apache.lucene.search.TotalHits) > [ERROR] method java.lang.Math.min(int,int) is not applicable > [ERROR] (argument mismatch; org.apache.lucene.search.TotalHits cannot be > converted to int) > [ERROR] method java.lang.Math.min(long,long) is not applicable > [ERROR] (argument mismatch; org.apache.lucene.search.TotalHits cannot be > converted to long) > [ERROR] method java.lang.Math.min(float,float) is not applicable > [ERROR] (argument mismatch; org.apache.lucene.search.TotalHits cannot be > converted to float) > [ERROR] method java.lang.Math.min(double,double) is not applicable > [ERROR] (argument mismatch; org.apache.lucene.search.TotalHits cannot be > converted to double) > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org