RE: Using @index for hydra collection? - was: Re: Reading hydra:Collection as link relation

On 8 Mrz 2015 at 10:51, Dietrich Schulten wrote:
> Am 04.03.2015 um 22:54 schrieb Markus Lanthaler:
>> On 27 Feb 2015 at 07:26, Dietrich Schulten wrote:
>>> Seen that way I think I can make peace with our collection design :)
>> 
>> Good :-)
> 
> ;-)
> 
> That doesn't mean I find the collection design particularly elegant. But
> as a vocabulary, we probably have no other means in hydra right now.
> 
> What makes it not elegant is the fact that we now have two linking
> facilities, and clients must check both to find all related remote items
> of the current context.

Yes, that's quite unfortunate but unfortunately outside of our control.


> To make it easier for clients to find their way
> through our related collections, one could @index them by the property
> each collection manages.

That makes it easier for humans looking at the data (or for programmers which program against the JSON structure). For clients it shouldn't make any difference.


> It would be much easier to find the
> :acceptedOffer and :review link if the value of :collection were an
> indexed json object as shown below. If everybody agrees that @index
> would be very helpful here, we could make it a SHOULD, so clients can
> generally rely on the index.

You can easily achieve the same with some pre-processing on the client-side.. this is also something I would like to address in JSON-LD framing in the future. Unfortunately, I don't have the time to work on that at the moment :-(


> {
>   "@context": {
>     "@vocab": "http://schema.org",
>     "hydra:collection": {
>       "@container": "@index"
>     }
>   },
>   "@id": "http://example.com/store",
>   "hydra:collection":
>     {
>       "http://schema.org/acceptedOffer": {
>         "@id": "http://example.com/store/acceptedOffers",
>         "hydra:manages": {
>           "hydra:property": "acceptedOffer",
>           "hydra:subject": "http://example.com/store"
>         }
>       },
>      "http://schema.org/review": {
>         "@id": "http://example.com/store/reviews",
>         "hydra:manages": {
>           "hydra:property": "review",
>           "hydra:subject": "http://example.com/store"
>         }
>       }
>     }
> }
> 
> We might even say that a hydra client may expect as index:
> - an absolute http URL,
> - a curie (whose prefix is in the @context) or
> - a non-URI or curie value that should be prefixed by the default vocab
> prefix defined by @vocab.

And this really shows how brittle it is to rely on such "hacks".


> I think that is as good as it gets with the current json-ld spec.
> 
> But I still hope that we can have the elegant way some day, see subject
> "Enhance json-ld to allow remote collections" :)

This is not a JSON-LD issue but an RDF issue IMO. You can't address a set of arcs (links) in RDF. You have to introduce an intermediary node (collection) to work around the limitation.


--
Markus Lanthaler
@markuslanthaler

Received on Friday, 13 March 2015 17:45:03 UTC