Lucene 6.1: number of hits per document

2016-08-25 Thread szzoli
Hi, I would like to get the number of hits per document. I googled around a lot, there were code snipplets for older versions. None of them works with Lucene 6.1. Any help would be appreciated. -- View this message in context: http://lucene.472066.n3.nabble.com/Lucene-6-1-number-of-hits-per-d

Re: Lucene 6.1: number of hits per document

2016-08-28 Thread Adrien Grand
What do you mean by "number of hits per documents"? Can you give an example maybe? Le jeu. 25 août 2016 à 16:29, szzoli a écrit : > Hi, > > I would like to get the number of hits per document. > I googled around a lot, there were code snipplets for older versions. None > of them works with Lucen

Re: Lucene 6.1: number of hits per document

2016-08-29 Thread szzoli
I was searching for a word in an index (multiple files were indexed in a library). I was searching e.g for "run". A document contained two times, an other three times this word. I would like to see int the result for the firs document "2", for the other "3". Thank you Adrien Grand wrote > What

Re: Lucene 6.1: number of hits per document

2016-08-29 Thread Adrien Grand
Le lun. 29 août 2016 à 12:00, a écrit : > I was searching for a word in an index (multiple files were indexed in a > library). I was searching e.g for "run". A document contained two times, an > other three times this word. > I would like to see int the result for the firs document "2", for the >

Re: Lucene 6.1: number of hits per document

2016-08-29 Thread Mikhail Khludnev
try fl=*,tf(text,'run') or check explanation on debugQuery=true it's present in lines with termFreq or tf() On Mon, Aug 29, 2016 at 1:02 PM, szzoli wrote: > I was searching for a word in an index (multiple files were indexed in a > library). I was searching e.g for "run". A document contained tw

Re: Lucene 6.1: number of hits per document

2016-08-31 Thread szzoli
I used: Analyzer analyzer = new StandardAnalyzer(); QueryParser parser = new QueryParser(field, analyzer); Query query = parser.parse(queryString); TermQuery cannot be created this way. Scorer.freq(), Collector.setScorer() how can be obtained?

RE: Lucene 6.1: number of hits per document

2016-08-31 Thread Uwe Schindler
Original Message- > From: Mikhail Khludnev [mailto:m...@apache.org] > Sent: Monday, August 29, 2016 2:17 PM > To: java-user@lucene.apache.org > Subject: Re: Lucene 6.1: number of hits per document > > try fl=*,tf(text,'run') > or check explanation on debugQuery=true &

Re: Lucene 6.1: number of hits per document

2016-09-01 Thread szzoli
Adrien: "If the Query is a TermQuery, you can get this number by calling Scorer.freq() on the Scorer that is passed to Collector.setScorer()." My problem is that I do not know how can one get Scorer.freq(). Scorer is an abstect class. It has many deived classes. I don't know wich one to use. The

Re: Lucene 6.1: number of hits per document

2016-09-01 Thread Adrien Grand
Maybe you should clarify your use-case. For instance Uwe was assuming that you needed this information for debugging purposes while I was assuming that you needed it for your application logic. Le jeu. 1 sept. 2016 à 14:20, szzoli a écrit : > "If the Query is a TermQuery, you can get this number

Re: Lucene 6.1: number of hits per document

2016-09-01 Thread szzoli
I created a collector with SimpleCollector collector = new TotalHitCountCollector(); but when I wanted to call collector.setScorer(scorer); the scorer has again several parameters: Scorer scorer = new ConstantScoreScorer(Weight, float, disi); Do I have to create these objects, too? -- View this

Re: Lucene 6.1: number of hits per document

2016-09-01 Thread Adrien Grand
IndexSearcher will call LeafCollector.setScorer(Scorer) for you when you call IndexSearcher.search(Query, Collector). All you need to do is to keep a reference to this Scorer object and use it in the LeafCollector.collect(int) method. Le jeu. 1 sept. 2016 à 14:42, szzoli a écrit : > I created a

Re: Lucene 6.1: number of hits per document

2016-09-01 Thread szzoli
I call IndexSearcher.search(Query, Collector) but it is void. Where can I obtain the Scorer object? collector.getTotalHits() seems to return the number of the documents. How can I tell it that it should count the hits in the approriate document? -- View this message in context: http://lucene.

Re: Lucene 6.1: number of hits per document

2016-09-02 Thread Adrien Grand
What is an "appropriate document"? This discussion looks like an XY problem where you are asking about freqs while the actual problem you are trying to solve is different. Anyway, here are two ways to get freqs, first only for the top docs and then inside a collector: http://pastebin.com/FfFy2Amp.

Re: Lucene 6.1: number of hits per document

2016-09-02 Thread szzoli
This link helped me, it contained the solution. Thank you! -- View this message in context: http://lucene.472066.n3.nabble.com/Lucene-6-1-number-of-hits-per-document-tp4293245p4294403.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --