You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Peyman Faratin <pe...@gmail.com> on 2013/12/17 04:05:04 UTC

docFreq of a Boolean query (LUCENE 4.3)

Hi

I know how to get the docFreq of a term in a single field (say "content" field)

int docFreqInIndex = indexReader.docFreq(new Term("content", q));

But is it possible to get the docFreq of a boolean query consisting of matches across two or more fields? For instance, 

BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(new BooleanClause(new TermQuery(new Term("content", q)) , Occur.MUST));
booleanQuery.add(new BooleanClause(new TermQuery(new Term("publisher", q2)) , Occur.MUST));

docFreq API does not accept a booleanQuery. 

docFreqInIndex = indexReader.docFreq(booleanQuery);

what would be the best solution to this?
thank you


RE: docFreq of a Boolean query (LUCENE 4.3)

Posted by "Allison, Timothy B." <ta...@mitre.org>.
TotalHitCountCollector?

Others on the list may have a more efficient method, but that'd be straightforward.

-----Original Message-----
From: Peyman Faratin [mailto:peymanfaratin@gmail.com] 
Sent: Monday, December 16, 2013 10:05 PM
To: java-user@lucene.apache.org
Subject: docFreq of a Boolean query (LUCENE 4.3)

Hi

I know how to get the docFreq of a term in a single field (say "content" field)

int docFreqInIndex = indexReader.docFreq(new Term("content", q));

But is it possible to get the docFreq of a boolean query consisting of matches across two or more fields? For instance, 

BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(new BooleanClause(new TermQuery(new Term("content", q)) , Occur.MUST));
booleanQuery.add(new BooleanClause(new TermQuery(new Term("publisher", q2)) , Occur.MUST));

docFreq API does not accept a booleanQuery. 

docFreqInIndex = indexReader.docFreq(booleanQuery);

what would be the best solution to this?
thank you


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org