Hacker News new | ask | show | jobs
by smhinsey 5568 days ago
A search with multiple return types is a good question when the results are JSON, but if the result is something like Atom, it's not really an issue at all because each entity in the resulting feed can contain its own type descriptors. Unfortunately it's since been replaced by a new CMS after I left several years ago, but the search for newsweek.com used to work like this.
2 comments

The larger problem I see with regards to REST is: what resource are you hitting that would give you multiple types? Meta resources like /media, /things, etc aren't ideal; is there a better way to do it?
I am not sure that this is the canonical approach, but the way I did it was to model my search index as the resource. Requesting it with no parameters returned the entire index in its natural sort. Additional parameters filtered/sorted/paged/etc.
I'm confused, why would JSON vs. Atom make a difference in this case? What does Atom get you that you can't also do with JSON?
Atom has a well-defined way for expressing the content type of items in a feed. You can do this with JSON but you have to come up with your own system.