lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martijn v Groningen <>
Subject Re: How to use Query Time Join with Lucene 5.3.0?
Date Tue, 14 Jun 2016 08:55:08 GMT
The blog you're referring to is explaining the query time join
implementation that isn't using ordinal map, which is the first method in
the JoinUtil class (with the ordinal map as parameter).

If you want to use the method that uses global ordinals you can use this
snippet to create an OrdinalMap instance:

IndexReader r = indexSearcher.getIndexReader();
SortedDocValues[] values = new SortedDocValues[r.leaves().size()];
for (int i = 0; i < values.length; i++) {
  LeafReader leafReader =  r.leaves().get(i).reader();
  values[i] = DocValues.getSorted(leafReader, joinField);
MultiDocValues.OrdinalMap ordinalMap =
  r.getCoreCacheKey(), values, PackedInts.DEFAULT

I copied this snippet from this test:

If you use this join implementation it is important that you reuse the
OrdinalMap as it is expensive to create. Reuse the ordinal map as long as
you use the IndexReader, if (re)open an new IndexReader you should build a
new ordinal map.

On 13 June 2016 at 08:14, Pravin Thokal <> wrote:

> I am referring this
> <>link for
> usage of query time join and I am able to use following method
>    createJoinQuery(String fromField, boolean multipleValuesPerDocument,
> String toField, Query fromQuery, IndexSearcher fromSearcher, ScoreMode
> scoreMode)
> Parameters:
> fromField - The from field to join from
> multipleValuesPerDocument - Whether the from field has multiple terms per
> document
> toField - The to field to join to
> fromQuery - The query to match documents on the from side
> fromSearcher - The searcher that executed the specified fromQuery
> scoreMode - Instructs how scores from the fromQuery are mapped to the
> returned query
> However I would like to use following createJoinQuery() with different
> parameters
> public static Query createJoinQuery(String joinField,Query fromQuery,
>                 Query toQuery,IndexSearcher searcher,ScoreMode scoreMode,
>                 MultiDocValues.OrdinalMap ordinalMap) throws IOException
> joinField - The SortedDocValues field containing the join values
> fromQuery - The query containing the actual user query. Also the fromQuery
> can only match "from" documents.
> toQuery - The query identifying all documents on the "to" side.
> searcher - The index searcher used to execute the from query
> scoreMode - Instructs how scores from the fromQuery are mapped to the
> returned query
> ordinalMap - The ordinal map constructed over the joinField. In case of a
> single segment index, no ordinal map needs to be provided.
> For this methods, I am referring this
> <
> >link.
> I don't have any clue for the parameter ordinalMap and how to create it. It
> will be great help if any one explains it with example.
> Best Regards,
> *Pravin Thokal*
> *Senior Product Engineer,*
> *SysTools Software Pvt. Ltd.*
> 202, Pentagon P3, Magarpatta CyberCity, Pune - 411028 , Maharashtra, India.
> +91-02-60505558 | |

Met vriendelijke groet,

Martijn van Groningen

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message