As an example of Mikhail's suggestion: https://github.com/tballison/lucene-addons/blob/master/lucene-5317/src/main/java/org/apache/lucene/search/concordance/charoffsets/SpansCrawler.java
If you are trying to build a concordance, see ConcordanceSearcher in that package. See examples on how to run the ConcordanceSearcher here: https://github.com/tballison/lucene-addons/blob/master/lucene-5317/src/test/java/org/apache/lucene/search/concordance/TestConcordanceSearcher.java Let me know if you have any questions/if the bad behavior still exists. Finally, be aware of this potential deal-breaker with SpanQueries: https://issues.apache.org/jira/browse/LUCENE-7398 ("Nested SpanQueries are buggy") Cheers, Tim -----Original Message----- From: Mikhail Khludnev [mailto:m...@apache.org] Sent: Tuesday, June 20, 2017 4:24 AM To: java-user@lucene.apache.org Subject: Re: Correction: SpanNearQuery Class issue through spans object (Not through Searcher.search() method) Hello Ranganath, I guess you need to loop through LeafReaderContexts, create scorer/span for them to get to 7th crore and beyond. On Tue, Jun 20, 2017 at 10:59 AM, Ranganath B N <ranganath....@huawei.com> wrote: > Hi, > > > This is regarding the search limit of SpanNearQuery Class. I > create a lucene index consisting of 2 billion documents . > Then obtain a spans object through getspans method of Spanweight > object created from SpanNearQuery object. Then I get the > matching documents by iterating through spans.nextdoc(). But searching > through spans object returns results only if search terms are > within first 6 crore inserted documents. Am I missing anything > during initialization so that search is getting restricted or is this > a limitation issue with SpanNearQuery Class? > I am using Apache lucene 6.5.0 version. Please let me know about this > since I am using this for a critical project? > > Thanks, > Ranganath B. N. > > -- Sincerely yours Mikhail Khludnev