Hi Adrien,
Thank you for the explanation.
Here is what I have ended up with.
BooleanQuery.Builder builder = new BooleanQuery.Builder();
builder
.add(new MatchAllDocsQuery(), BooleanClause.Occur.FILTER)
.add(new TermQuery(term), BooleanClause.Occur.MUST_NOT);

Ahmet

On Friday, August 11, 2017, 3:58:25 PM GMT+3, Adrien Grand <jpou...@gmail.com> 
wrote:


FILTER does the opposite of MUST_NOT.

Regarding scoring, putting the query in a FILTER or MUST_NOT clause is good
enough since such clauses do not need scores. You do not need to add an
additional ConstantScoreQuery wrapper.

Le mar. 8 août 2017 à 23:06, Ahmet Arslan <iori...@yahoo.com.invalid> a
écrit :


> Hi all,
> I am trying to access document lenght statistics of the documents that do
> not contain a given term.
> I have written following piece of code
>
> BooleanQuery.Builder builder = new BooleanQuery.Builder();builder.add(new
> MatchAllDocsQuery(), BooleanClause.Occur.MUST)        .add(new
> TermQuery(term), BooleanClause.Occur.FILTER);
> ScoreDoc[] hits = searcher.search(new ConstantScoreQuery(builder.build()),
> Integer.MAX_VALUE).scoreDocs;
> Javadoc says FILTER is like MUST except that these clauses do not
> participate in scoring.
> I was expecting FILTER behaves like MUST_NO, no? (FILTER-clause is
> excluded from the result set)
>
> Also, to disable scoring altogether, is it enough to wrap final boolean
> query using ConstantQuery?Or individual clauses should be wrapped to?
> MatchAllDocsQuery is already ConstantQuery, right?
> Thanks,Ahmet
>

Reply via email to