New issue 406 by m.d.na...@hetnet.nl: Add setting that makes Listfacet
combine its selection as AND instead of OR.
There are several requests on the mailing list for a list facet that
returns those items that have all of the chosen options in the list facet
instead of any one of the chosen options as is the case with the present
implementation (trunk revision 2140). I tried to implement this and the
result is in the attached file "andListfacet.js".
If this file is loaded after the exhibit code is loaded, it adds an extra
setting with the name "combineMode" to listfacets. The default of this
setting is "or" which keeps the current behavior. If combineMode is set
to "and" the facet is to behave in the requested manner. So code within
your exhibit html file typically looks like:
<div ex:role="facet" ex:expression=".property" ex:combineMode="and"></div>
Please give this code a try, and report positive and negative results here
on the issue tracker, because it has not seen much testing.
andListfacet.js 8.9 KB
hi Michiel, this is a great addition - i've needed this for a long time.
i just tried it, and it seems to work just fine.
I tried out your patch and it works well. The only problem I see is that
the counts and available items within a single list-facet are not updated
to reflect the fact that the facet intersects versus unions. For my
use-case, it's useful to see the number of items that would result by
selecting an additional restriction in the list facet.
The counts are updated when the Exhibit.ListFacet.update is called. It's
called with the set of items that are available to the facet -- if this
list-facet is the only one with restrictions, it updates it with the all
the available items. If it is not the only one, then it is updated with the
intersection of all available items from the other facets. The logic for
all this is in Exhibit.Collection._updateFacets.
To fix the counts for the intersect case, on a ListFacet.update(), I just
called restrict() on the set of items given before calculating the counts
if the list-facet is in intersection mode. This makes the counts limited
only to values arising from items in the intersection of the currently
The attached patch to andListfacet.js accomplishes this. It's a straight
copy of Exhibit.ListFacet.prototype._computeFacet from SVN r2153, except
lines 3-7 of the method are the restrict() call I describe above. It works
well for me.
intersectionCounts.patch 1.9 KB
Just a note to say I find this change (Michiel with Russell's additions)
really helpful for my particular project (a database of thousands of
academic journal articles, with various keywords acting as the facets.)
Thanks to you both for your contributions.