Short answer is, no, the list facet doesn't support that, yet. The
challenge isn't so much in the algorithms, but in the UI. For one thing,
the choice counts will be different and harder to understand in the AND
case.
David
This hack works for my example - a scenario to find SetA AND SetB
values.
How to get a NOT dataset for facets?
e.g.
SetA = 25 (13 only A, 12 common with B)
SetB = 27 (15 only B, 12 common with A)
SetA intersect setB = 12 (common) (using hack)
SetA union (or) setB = 13 + 15 + 12 = 40 (using usual facet)
How to get values that are in SetA but NOT in Set B = 13 (only A)?
Thanks,
Mahesh Kulkarni.
---------- Forwarded message ----------
From: David Huynh <dfhu...@alum.mit.edu>
Date: Mar 18 2009, 1:26 pm
Subject: "AND" between facet values
To: SIMILE Widgets
Luigi Spagnolo wrote:
>> It's a hack, but you can do it by making two facets on the same
>> property. Exhibit will "and" between the selections on the two facets.
> Thank you for your answer.
> However, this seems to be not a suitable solution for my needs: if I
> need to compute an AND between N (with N arbitrary and not predictable
> in advance) values of the same proterty, I would need N facets;
> moreover, it would be very confusing for users to have multiple facets
> that control the same property.
> So this is the only possible solution/workaround?
> Maybe it would be useful to introduce a new parameter for facets that
> permits to specify if the multiple values selected may be combined
> with an OR or with an AND. This parameter could be also set
> dinamically by the user (e.g. with an option like "Filter items that
> satify: at least one costraint | all costraints" ).
Hi Luigi,
Short answer is, no, the listfacetdoesn't support that, yet. The
challenge isn't so much in the algorithms, but in the UI. For one
thing,
the choice counts will be different and harder to understand in the
AND
case.
David- Hide quoted text -
- Show quoted text -
I believe you would have to create a new kind of facet. Copy the source from
http://api.simile-widgets.org/exhibit/2.2.0/scripts/ui/facets/list-facet.js
and replace "ListFacet" with, say, "NotFacet". Then you'd need to change
2 methods (note the ***):
Exhibit.NotFacet.prototype.restrict = function(items) {
if (this._valueSet.size() == 0 && !this._selectMissing) {
return items;
}
var set = this._cache.getItemsFromValues(this._valueSet, items);
if (this._selectMissing) {
this._cache.getItemsMissingValue(items, set);
}
items.removeSet(set); // ***
return items; // ***
};
Exhibit.NotFacet.prototype._computeFacet = function(items) {
var database = this._uiContext.getDatabase();
var r = this._cache.getValueCountsFromItems(items);
var entries = r.entries;
var valueType = r.valueType;
if (entries.length > 0) {
var selection = this._valueSet;
var labeler = valueType == "item" ?
function(v) { var l = database.getObject(v, "label");
return l != null ? l : v; } :
function(v) { return v; }
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
entry.actionLabel = entry.selectionLabel =
labeler(entry.value);
entry.selected = selection.contains(entry.value);
entry.count = items.size() - entry.count; // ***
}
entries.sort(this._createSortFunction(valueType));
}
if (this._settings.showMissing || this._selectMissing) {
var count = items.size() -
this._cache.countItemsMissingValue(items); // ***
if (count > 0 || this._selectMissing) {
var span = document.createElement("span");
span.innerHTML = ("missingLabel" in this._settings) ?
this._settings.missingLabel :
Exhibit.FacetUtilities.l10n.missingThisField;
span.className = "exhibit-facet-value-missingThisField";
entries.unshift({
value: null,
count: count,
selected: this._selectMissing,
selectionLabel: span,
actionLabel:
Exhibit.FacetUtilities.l10n.missingThisField
});
}
}
return entries;
}
I think that's it, but let me know if that doesn't work for you.
David