Re: collection / facets

Hi,

taking an example to make things easier to explain.
Let's say that the server wants to return, in the description of </alice/friends>, the set of the interests (foaf:topic_interest) they have (not the list of interests of each friend, but the set of all the interests that at least one of Alice's friends has). In a client GUI, you can then click one of these interests to filter the list of friends and return only the friends who have this interest.

I'll try to do that using hydra. Currently, here is what I basically do, using a "facet vocabulary" of my own:

</alice/friends> a hydra:Collection ;
	hydra:member </bob>,</markus> ;
	facet:facet </alice/friends/topic_interests>.

</alice/friends/topic_interests> a facet:Facet;
	facet:property foaf:topic_interest ;
	facet:item [
		a facet:Item;
		facet:linkLabel dbpedia:jsonld;
		facet:href </alice/friends?variable=foaf:topic_interest&value=dbpedia:jsonld>  # url encoding of the params needed here
	] ;
	facet:item [
		a facet:Item;
		facet:linkLabel dbpedia:cats;
		facet:href </alice/friends?variable=foaf:topic_interest&value=dbpedia:cats>  # url encoding of the params needed here
	] ;
	facet:item [
		a facet:Item;
		facet:linkLabel dbpedia:music;
		facet:href </alice/friends?variable=foaf:topic_interest&value=dbpedia:music>  # url encoding of the params needed here
	].

of course the client has to know this facet vocabulary to display a GUI (although it degrades almost gracefully if it doesn't), but it is quite simple: to display a Facet, loop over the values of facet:item. For each, create an HTML link
	- using the value of facet:href as href
	- labelled with:
		- the value of facet:linkLabel if it is a litteral,
		- the rdfs:label of it when it is a resource (as it is the case in the example. When the values of facet:property are resources, I prefer keeping a resource as value of facet:linkLabel, rather than using a label, because it gives the exact meaning of the facetItem. If I want to directly pass the label of the link to the client, to make its life easier, I set the rdfs:label of the facet:Item.)

Trying to translate that to hydra, using hydra:filter as suggested, here is the description of alice/friends that I am able to come up with:

{
    "@id": "http://localhost/alice/friends",
    "@type": "hydra:Collection",
    "hydra:member": [
        {
          "@type": "foaf:Person",
          "@id": "http://localhost/bob",
        },{
          "@type": "foaf:Person",
          "@id": "http://localhost/markus",
        }
    ],
    
    # list of related values of foaf:topic_interest

    "hydra:collection": {
	"@id": "http://localhost/alice/friends/topic_interests"
        "@type": "hydra:Collection",
        "hydra:member": [
            {
              "@id": "dbpedia:jsonld"
            },{
              "@id": "dbpedia:cats"
            },{
              "@id": "dbpedia:music"
            }
        ]
#	that' not correct:
#	"hydra:manages" [
#		"hydra:property": "foaf: topic_interest",
#		"hydra:subject": "http://localhost/alice/friends"
    },

    # stating that the /alice/friends collection can be filtered by foaf:topic_interest

    "hydra:filter": {
        "@type": "hydra:IriTemplate",
        "hydra:template": "http://localhost/alice/friends?variable=foaf%40topic_interest&value={?val}",
        "hydra:mapping": [
        {
            "@type": "hydra:IriTemplateMapping",
            "hydra:variable": "val",
            "hydra:required": true,
            "hydra:property": "foaf:topic_interest"
        }]
    },
}

but it is not OK: we do not know that the values that can be used as ?val in the template are those listed in http://localhost/alice/friends/topic_interests.
How would you do that? Shouldn't be the whole http://localhost/alice/friends/topic_interests block be a property of the IriTemplate?

Best,

fps



Le 4 mars 2015 à 22:21, Markus Lanthaler <markus.lanthaler@gmx.net> a écrit :

> On 24 Feb 2015 at 15:21, François-Paul Servant wrote:
>> how would you describe facets using hydra?
> 
> We have two open issues that partly address this:
> 
>  https://github.com/HydraCG/Specifications/issues/45
>  https://github.com/HydraCG/Specifications/issues/16
> 
> 
> --
> Markus Lanthaler
> @markuslanthaler
> 
> 

Received on Sunday, 8 March 2015 14:50:34 UTC