Difference between revisions of "stoney core: Search Resource - REST API"

From stoney cloud
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Search helper)
Line 9: Line 9:
  
 
Reseller search example: <code>https://api.example.com/v1/resellers/?q=fluffy+dragon</code>. TBD. Diese Variante beschreiben.
 
Reseller search example: <code>https://api.example.com/v1/resellers/?q=fluffy+dragon</code>. TBD. Diese Variante beschreiben.
 +
 +
* number of entries returned '''per''' object type:
 +
** default: 5
 +
** max (can be raised by appropriate get parameters): 15
 +
 +
<source lang='javascript'>
 +
{
 +
  "resellers":
 +
  {
 +
    "resources":
 +
    [
 +
      { "id": 4000000, ... },
 +
      { "id": 4000001, ... }
 +
    ],
 +
    "location": "https://api.selfcare.com/v1/resellers/?q=fluffy+dragon"
 +
  },
 +
  "customers":
 +
  {
 +
    "resources":
 +
    [
 +
      { "id": 5000000, ... },
 +
      { "id": 5000001, ... }
 +
    ],
 +
    "location": "https://api.selfcare.com/v1/customers/?q=fluffy+dragon"
 +
  },
 +
  ...
 +
}
 +
</source>
  
  
 
[[Category: REST API]]
 
[[Category: REST API]]

Revision as of 17:29, 9 January 2014

Search helper

We want to provide an omni-search/ElasticSearch style search function and the most flexible approach is by doing the search completely on the server-side.

Therefore we are gonna copy the leader in search and define the URL for searching this way (see [1]):

https://api.example.com/v1/search?q=fluffy+dragon.

We already have a generic full-text search mechanism defined for all resources. Why not use the same mechanism but apply it on the root resource (https://api.example.com/v1/?q=fluffy+dragon), this way we don't have to break the REST principal (method versus resource). The search will then return simple JSON objects with a type and a location URI. The actual resources on which to apply the search filter, will be defined on the server side --Chrigu (talk) 15:24, 16 December 2013 (CET)

Reseller search example: https://api.example.com/v1/resellers/?q=fluffy+dragon. TBD. Diese Variante beschreiben.

  • number of entries returned per object type:
    • default: 5
    • max (can be raised by appropriate get parameters): 15
{
  "resellers":
  {
    "resources":
    [
      { "id": 4000000, ... },
      { "id": 4000001, ... }
    ],
    "location": "https://api.selfcare.com/v1/resellers/?q=fluffy+dragon"
  },
  "customers":
  {
    "resources":
    [
      { "id": 5000000, ... },
      { "id": 5000001, ... }
    ],
    "location": "https://api.selfcare.com/v1/customers/?q=fluffy+dragon"
  },
  ...
}