"AND" between facet values

29 views
Skip to first unread message

Luigi Spagnolo

unread,
Mar 16, 2009, 4:08:26 PM3/16/09
to SIMILE Widgets
Hello, I am new to Exhibit.
I ask you if there is a way to obtain an "AND" between values
belonging to the same facet.

Suppose that my items have a property that admits multiple values,
e.g. see the propery "artists" here:
{ type : "Museum",
label : "Louvre",
artists: ["Leonardo Da Vinci" , "Jacques-
Louis David"]
},
{ type : "Museum",
label : "Uffizi",
artists: ["Leonardo Da Vinci" , "Raffaello
Sanzio"]
},
{ type : "Museum",
label : "Prado",
artists: ["Francisco Goya" , "Diego
Velàsquez"]
}

If I create a facet for filtering museums by artists shown

<div ex:role="facet" ex:expression=".artists"
ex:facetLabel="Artists"></div>

How I can search for museums that show artworks by "Leonardo Da
Vinci" AND "Jacques-Louis David"?

If I select both "Leonardo Da Vinci" and "Jacques-Louis David" in
Exhibit, I actually obtain a list of museums that show artworks by
"Leonardo Da Vinci" OR "Jacques-Louis David". In my example I would
get both "Louvre" and "Uffizi", while my desired result would be
"Louvre" only.

How I can obtain this in Exhibit? Is there a parameter I can set, or
do I have to modify the code?

Thank you in advance

David Karger

unread,
Mar 16, 2009, 4:10:17 PM3/16/09
to simile-...@googlegroups.com
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.

Luigi Spagnolo

unread,
Mar 17, 2009, 7:48:58 AM3/17/09
to SIMILE Widgets
> 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" ).

David Huynh

unread,
Mar 18, 2009, 2:26:36 PM3/18/09
to simile-...@googlegroups.com
Hi Luigi,

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

Mahesh K.

unread,
Feb 17, 2010, 1:52:44 PM2/17/10
to simile-...@googlegroups.com
Hi 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 -

David Huynh

unread,
Feb 20, 2010, 7:20:17 PM2/20/10
to simile-...@googlegroups.com
Mahesh,

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

Reply all
Reply to author
Forward
0 new messages