lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: topdocs per facet
Date Thu, 09 Oct 2014 18:37:06 GMT
The facets translation should be done at the application level. So if you
index the dimension A w/ two facets A/A1 and A/A2, where A1 should also be
translated to B1 and A2 translated to B2, there are several options:

Index the dimensions A and B with their respective facets, and count the
relevant dimension based on the user's locale. Then the user can drill-down
on any of the returned facets easily. I'd say that if your index and/or
taxonomy aren't big, this is the easiest solution and most straightforward
to implement.

Another way is to index the facet Root/R1 and Root/R2, which are
language-independent. At the application level you translate Root/R1 to
either A/A1 or B/B1 based on the user locale. You also then do the reverse
translation when the user drills-down. So e.g. if the user clicked A/A1,
you translate that to Root/R1 and drill-down on that. If your application
is UI based, you probably can return e.g a JSON construct which contains
the labels to display + the facet values to drill-down by and then you
don't need to do any reverse translation.

As for retrieving a document's facets, you can either index them as
separate StoredFields (easy), or use DocValuesOrdinalsReader to traverse
the facets list along with the MatchingDocs, read the facet ordinals and
translate them. If it sounds complex, just use StoredFields :).

Shai

On Mon, Sep 29, 2014 at 7:15 PM, Jürgen Albert <j.albert@data-in-motion.biz>
wrote:

> Hi,
>
> I'm currently implementing the lucene facets in the version 4.8.1 and two
> questions remain for me:
>
> 1. Is the an easy way to have translations for the facets? If we use e.g.
> the books example, the user should see the translation. But if he clicks on
> a link the english value should be used for the search. Thus I have to
> return the facet translation and the actual value by the search.
> 2. Is there a possibility to get the docs per facet?
>
> As An example I have e.g. a DrillDownQuery returning 5 docs and 2
> dimensions with 2 facets each. I guess the solution is somewhere in the
> MatchingDocs.  If I try:
>
>             List<MatchingDocs> matchingDocs = facetsCollector.
> getMatchingDocs();
>
>             for(MatchingDocs doc : matchingDocs){
>                 DocIdSet docSet = doc.bits;
>                 DocIdSetIterator iterator = docSet.iterator();
>                 int docId = iterator.nextDoc();
>                 while (docId != DocIdSetIterator.NO_MORE_DOCS){
>                     Document document = doc.context.reader().document(
> docId);
>                     System.out.println(document.toString());
>                     docId = iterator.nextDoc();
>                 }
>             }
>
> result:
>
> A List with as much MachtingDocs as dimensions, but only one MatchDocs
> gives me my docs at all. How I could get the docs per facet I can't see at
> all, nor how  could get the facets of a doc.
>
> What do I miss?
>
> Thx,
>
> Jürgen Albert.
>
> --
> Jürgen Albert
> Geschäftsführer
>
> Data In Motion UG (haftungsbeschränkt)
>
> Kahlaische Str. 4
> 07745 Jena
>
> Mobil:  0157-72521634
> E-Mail: j.albert@datainmotion.de
> Web: www.datainmotion.de
>
> XING:   https://www.xing.com/profile/Juergen_Albert5
>
> Rechtliches
>
> Jena HBR 507027
> USt-IdNr: DE274553639
> St.Nr.: 162/107/04586
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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