lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: TermInSetQuery keep terms order in results
Date Mon, 25 Jun 2018 14:52:08 GMT

the TermInSetQuery is a so-called Constant Score Query. It is more meant as a filter, so you
would need some "real" fulltext query in parallel. See the term-in-set query more like the
SQL "IN" operator. It can be used to pass lots of identifiers to filter results (e.g. when
you apply access rights or group policies for filtering users to your main query as a filter).

As it is a "set", which is by default unordered, the order of terms in the set is undefined.
Internally TermInSetQuery reorders the terms to improve processing speed.

If you need scoring, use TermQuery wrapped by a BooleanQuery. Then you can apply some boosts
to some terms to improve order (e.g. boost term queries coming first) and apply on a field
without norms.

TermInSetQuery is fast because it neglects scoring and is just good at intersecting the terms
dict with the given terms set.


Uwe Schindler
Achterdiek 19, D-28357 Bremen

> -----Original Message-----
> From: Nicola Buso <>
> Sent: Monday, June 25, 2018 1:23 PM
> To:
> Subject: TermInSetQuery keep terms order in results
> Hi,
> I need to use the TermInSetQuery, but I would like to keep the sorting
> of the results based on the term set order provided. Currently seems
> using a index documents insertion order in the results.
> Is this already implemented somewhere or do I need to implement a
> CustomScoreQuery to calculate this score?
> Cheers,
> Nicola
> --
> Nicola Buso <>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message