Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Michael McCandless: ToChildBlockJoinQuery in Lucene

$
0
0
Inmy lastpost I described a known limitationof BlockJoinQuery: it joins in only one direction (fromchild to parent documents). This can be a problem because someapplications need to join in reverse (from parent to child documents)instead.

This is now fixed! Ijust committeda new query, ToChildBlockJoinQuery, to perform the joinin the opposite direction. I also renamed the previous queryto ToParentBlockJoinQuery.

You use it just like BlockJoinQuery, except in reverse:it wraps any other Query matching parent documents andtranslates it into a Query matching child documents. Theresulting Query can then be combined with other queriesagainst fields in the child documents, and you can then sort by childfields as well.

Using songs and albums as an example: imagine you index eachsong (child) and album (parent) as separate documents in a singledocument block. With ToChildBlockJoinQuery, you can nowrun queries like:

albumName:thunder AND songName:numb
or

albumName:thunder, sort by songTitle
Any query with constraints against album and/or song fields will work,and the returned hits will be individual songs (not grouped).

ToChildBlockJoinQuery will be available in Lucene 3.6.0and 4.0.

Viewing all articles
Browse latest Browse all 9364

Trending Articles