Query resource for 'keyword' parameter

36 views
Skip to first unread message

Mark P

unread,
Nov 23, 2014, 10:05:08 PM11/23/14
to restinp...@googlegroups.com

Consider the case where I have archived media on a file system.  The media could possible contain metadata and/or bookmarked content.  My query parameters for metadata within the media is as follows:  keyword, time (start and end) and ID
My query parameter for bookmarks within the media is as follows:  keyword, description

For adding or updating bookmarks to media I've considered: 
POST /media/{id}/bookmark  
<XML within the entity body>

Alternative being considered: 
POST /bookmark
<XML within the entity body>  

At issue.  What's an appropriate query resource that'll capture querying of 'keyword' for metadata and/or bookmarks?  For instance given:

GET /media?keyword={}   

The immediate question becomes, which keyword?    
Solution 1:  Server could return a representation that includes both metadata and bookmarked content that matches the 'keyword'
Solution 2:  Design a URI that creates a delineation between keyword for metadata and bookmarks.  What should this look like?

Jim Webber

unread,
Nov 24, 2014, 5:43:48 PM11/24/14
to restinp...@googlegroups.com
Hi Mark,

> GET /media?keyword={}

Seems sane enough to me. You provide a keyword or keywords in a list.

> Solution 1: Server could return a representation that includes both metadata and bookmarked content that matches the 'keyword'

Server could return links to representations that match the keywords? The content of those representations could be any or all of data, metadata, keywords, bookmarks.

> Solution 2: Design a URI that creates a delineation between keyword for metadata and bookmarks. What should this look like?

Can you distinguish between "metadata" resources and "bookmark" resources by simply:

.../bookmark/...
and
.../metadata/...

Assuming the content types all line up.

Jim

Mark P

unread,
Nov 25, 2014, 3:26:17 PM11/25/14
to restinp...@googlegroups.com


Hi Jim,



> Solution 1:  Server could return a representation that includes both metadata and bookmarked content that matches the 'keyword'

Server could return links to representations that match the keywords? The content of those representations could be any or all of data, metadata, keywords, bookmarks.

> Solution 2:  Design a URI that creates a delineation between keyword for metadata and bookmarks.  What should this look like?

Can you distinguish between "metadata" resources and "bookmark" resources by simply:

.../bookmark/...
and
.../metadata/...

Assuming the content types all line up.

With this approach what's the query string for  keywords in bookmark and metadata

/bookmark?keyword={}
/metadata?keyword={}

How do you combine the two?  i.e.  how do I search for a specific keyword in bookmark and metadata without sending two separate query requests.  Also is it considered good practice to add a query string to each resource (ex: /bookmark? and /metadata?) or use one resource for querying?


or
/media/metadata
/media/bookmark


Mark

Jim Webber

unread,
Nov 25, 2014, 3:39:10 PM11/25/14
to restinp...@googlegroups.com
Hi Mark,

> With this approach what's the query string for keywords in bookmark and metadata

I'd assumed the client knows that. If not, then there needs to be another resource that links to the relevant bookmark and metadata resources. If the representation of that resource is human-readable, then you can helpfully add query string keywords in there.

> /bookmark?keyword={}
> /metadata?keyword={}
>
> How do you combine the two? i.e. how do I search for a specific keyword in bookmark and metadata without sending two separate query requests. Also is it considered good practice to add a query string to each resource (ex: /bookmark? and /metadata?) or use one resource for querying?

URIS are opaque. So it's quite legitimate to have a resource for bookmarks, a resource for metadata and a resource for bookmarks-and-metadata.

Being pedantic about URI opacity:

A Bookmark:

/abed7461ff771

A Metadata item:

/e77110ead05

A bookmark and metadata resource:

/71067ade7114

But if you wanted to make the URIs friendlier (but still opaque):

/bookmark/1
/metadata/27
/bookmarkAndMetadata/41

Or

/bookmark/{keywords}
/metadata/{keywords}
/bookmarkAndMetadata/{keywords}

Jim



Mark P

unread,
Nov 26, 2014, 7:19:57 AM11/26/14
to restinp...@googlegroups.com

Hi Jim, 
So from a '?' perspective I can have
 /metadata? 
 /bookmark?


Hence:
  /metadata?keywords={}&ID={}&Sign={}&Designation={}
  /bookmark?keywords={}&time={start,end}&Description={}  

Seems reasonable? 

And as mentioned before, to search for keyword belonging to bookmarks and metadata

  /boomarkAndMetadata/{keyword}

Jim Webber

unread,
Nov 26, 2014, 10:12:22 AM11/26/14
to restinp...@googlegroups.com
Hi Mark,

Hence:
  /metadata?keywords={}&ID={}&Sign={}&Designation={} 
  /bookmark?keywords={}&time={start,end}&Description={}   

Seems reasonable? 

Yup. Your server can read some useful structure into that, your clients treat it as opaque.

And as mentioned before, to search for keyword belonging to bookmarks and metadata 

  /boomarkAndMetadata/{keyword}

Yup again. And ditto the opacity.

Jim

Reply all
Reply to author
Forward
0 new messages