4417Re-using information fields for queries in REST
- Jun 1, 2004Hey all,
I was wondering about the best way to RESTfully model information
retrievals versus queries in REST. Imagine an Artist structure with
name, genre, albums, rating, etc. I want to both search for Artists
that approximate the name or albums, or exactly match a genre or
rating. As well, I want to retrieve a given Artist's information.
The retrieval is easy, with something like GET /Artist?
name=thieverycorp retrieving the structure.
But then if want to do a search, I was thinking the best rest way of
modeling is to make a Query structure that contains all the Artist
queryable information, maybe it's even the same type, and then have
an ArtistList resource. Then I could say that any of the ArtistQuery
fields can be put in the URI, ie
GET /ArtistList?name=thieverycorp or GET /ArtistList?albums=blue.
I can't see a way of using the same URI base for both retrievals and
queries without doing some funky parameters in the URI. There's a
variety of other techniques, like appending the requested return type
(GET /Artist?name=thieverycorp&type=ArtistList), the number of
results to return (GET /Artist?name=thieverycorp&rows=1), etc. but
they all seem a bit .... goofy.
Any help on the best way to model this would be appreciated. I'm
pretty sure this is almost an FAQ kind of question, so even a pointer
would be great.
- Next post in topic >>