This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Search Implementation in REST Service  RSS feed

 
Ranch Hand
Posts: 386
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are developing the RESTful services for search operations. As per REST Specs, since we are fetching the data from the server, it must be GET HTTP Method. But, we have to search on a huge number of parameters and this list can extend in future too. And, there is a limit to the query URL length, so, all search parameters can't be able to fit in the query URL. So, how can we implement this search?
 
Saloon Keeper
Posts: 5229
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By using POST. Why would REST principles forbid using POST for a search?
 
Saloon Keeper
Posts: 9707
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really forbid, but POST is used when you want to make a non-idempotent change on the server. I agree with Vaibhav that a GET is more appropriate.

However, when technical limitations bind your hands, you don't really have a choice. I would use PUT rather than POST though, as PUT indicates you can replay the request and it will return the same results, as long as the server state hasn't changed between the two requests.
 
Marshal
Posts: 67226
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A past implementation:

A POST is used to create a re-usable search query resource. A GET is used to fetch the results of running a parameterized search using the query resource.

Pure REST.
 
Saloon Keeper
Posts: 2350
293
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vaibhav Gargs wrote:We are developing the RESTful services for search operations. As per REST Specs, since we are fetching the data from the server, it must be GET HTTP Method. But, we have to search on a huge number of parameters and this list can extend in future too.


Your RESTful API should be focused on the exchange of specific resources.  When GETing a resource from a server, the client should already know what type of resource it wants the server will provide, and the majority of the parameters which describe the resource should be in the URI's resource path, not query parameters.  A quick example:

RESTful:
    GET /api/auto/dodge/caliber/2015/parts/engine/cooling/hose/intake&engine=2.2L

Not RESTful:
    GET /api/search?category=auto&type=parts&system=engine&subsystem=cooling&item=hose&use=intake&make=dodge&model=caliber&year=2015&engine=2.2L

 
Stephan van Hulst
Saloon Keeper
Posts: 9707
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a source for that Ron? What makes it not RESTful?
 
Ron McLeod
Saloon Keeper
Posts: 2350
293
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Do you have a source for that Ron? What makes it not RESTful?


In my example, the path /api/search does not describe a resource, it describes a operation.
 
Stephan van Hulst
Saloon Keeper
Posts: 9707
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair point.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i am working on something that will completely eliminate the need for coding for setting up a web server for answering REST web services or needing to sign up to a database provider like Oracle Rest Data services. The solution will allow business users to create dataflows and workflows for defining business logics for individual responses for REST requests.


I am just interested in knowing how much this project will gain traction among business users and developers.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!