Oh, ok, if that's just a regular query, you will need to convert it to a SpanQuery, and you may need to rewrite the SpanQuery after conversion.
If you're trying to do a concordance or trying to retrieve windows around the hits, take a look at ConcordanceSearcher within: https://github.com/tballison/lucene-addons/tree/master/lucene-5317 . With any luck, I should find the time to get back to the Solr wrapper under solr-5411 that Jason Robinson initially developed. -----Original Message----- From: Test Test [mailto:andymish...@yahoo.fr] Sent: Tuesday, April 07, 2015 3:51 PM To: solr-user@lucene.apache.org Subject: Re: Trouble GetSpans lucene 4 Re, origQuery is a Query object, i got it from a ResponseBuilder object, passed by the method getQuery. ResponseBuilder rb // it's method parameterQuery origQuery = rb.getQuery(); Thanks for the link, i'll keep you informed. Regards,Andy Le Mardi 7 avril 2015 20h26, "Allison, Timothy B." <talli...@mitre.org> a écrit : What class is origQuery? You will have to do more rewriting/calculation if you're trying to convert a PhraseQuery to a SpanNearQuery. If you dig around in org.apache.lucene.search.highlight.WeightedSpanTermExtractor in the Lucene highlighter package, you might get some inspiration. I have a hack for converting regular queries to SpanQueries here (this is largely based on WeightedSpanTermExtractor): https://github.com/tballison/lucene-addons/blob/master/lucene-5317/src/main/java/org/apache/lucene/search/spans/SimpleSpanQueryConverter.java -----Original Message----- From: Compte Poubelle [mailto:andymish...@yahoo.fr] Sent: Tuesday, April 07, 2015 1:53 PM To: solr-user@lucene.apache.org Subject: Re: Trouble GetSpans lucene 4 Up. Anyone? Best regards. > On 6 avr. 2015, at 21:32, Test Test <andymish...@yahoo.fr> wrote: > > Hi, > I'm working on TamingText's book.I try to upgrade the code from solr 3.6 to > solr 4.10.2.At the moment, i have a problem about the method > "getSpans"."spans.next()" returns always "false".Anyone can helps? > SpanNearQuery sQuery = (SpanNearQuery) origQuery;SolrIndexSearcher searcher = > rb.req.getSearcher();IndexReader reader = > searcher.getIndexReader();//AtomicReader wrapper = > SlowCompositeReaderWrapper.wrap(reader);Map<Term, TermContext> termContexts = > new HashMap<Term, TermContext>();//Spans spans = > sQuery.getSpans(wrapper.getContext(), new > Bits.MatchAllBits(reader.numDocs()), termContexts);while (spans.next() == > true) {//} > > Thanks.Regards. >