Changes

stoney core: Search Resource - REST API

8,342 bytes added, 10:51, 3 August 2014
/* Overview */
=== Also visit [[stoney core: Search helper ===We want to provide an omniResource Mapping (REST -search/ElasticSearch style search function LDAP)]] and the most flexible approach is by doing the search completely on the server-side[[stoney core: Global Searches]].
Therefore we are gonna copy the leader in = Overview =The search and define resource provides a full text search over all the URL for searching this way (see available resources. The available resources are:* The main framework called [[https://blog.apigee.com/detail/restful_api_design_tips_for_searchCategory:stoney core|stoney core])] is responsible for shared functionality.* The [[:Category:Self-Service Modules|Self-Service Modules]] expand the initial stoney cloud functionality.
A search could look as follows:* <code>https://api.example.com/v1/search?q=fluffy+dragon&entries=15</code>.
We already have a generic [[#Filtering.2C_sorting_and_searching|full-text search]] mechanism defined The following rules apply:* The minimum number of characters for all resources. Why not use the same mechanism but apply it on the root resource (<code>https://apiquery are 3.example.com/v1/?q=fluffy+dragon</code>), this way we don* Number of entries returned '''t have to break the REST principal (method versus resource). The search will then return simple JSON objects with a per''' object type and a location URI. The actual resources on which to apply the search filter, will be defined on the server side --[[User:Chrigu|Chrigu]] ([[User talk** Default: 5** Maximum:Chrigu|talk]]) 15:24, 16 December 2013 (CETcan be raised by '''entries''' get parameter)
Reseller search example= stoney core: <code>https://api.example.com/v1/resellers/?qsearch resource methods =fluffy+dragon</code>. TBD. Diese Variante beschreibenAs described above, each resource has its own search methods.The current stoney core resources are:* [[stoney core: Resellers Resource - REST API]]* [[stoney core: Customers Resource - REST API]]* [[stoney core: People Resource - REST API]]
The following special resources don't have additional search methods:
* [[stoney core: Authentication Resource - REST API]]
== Global Search (GET) ==Also visit [[stoney core: Search Resource Mapping (REST - LDAP)]] and [[stoney core: Global Searches]]. To form a global fulltext search (over all resources), append the url query parameter '''q''' with the desired search text: <code>https://api.example.com/v1/search?q=example</code>. === Global Search Request Message ==={| class="wikitable sortable" style="width: 100%;"|-! HTTP request part! Content! Example |-| Request lines|<pre>GET <Request-URI> HTTP 1.1HOST: <Host></pre>|<pre>GET /v1/search?q=example HTTP 1.1HOST: api.example.com </pre>  |-| Request headers| <pre>Accept: <Type>/<Subtype>Accept-Charset: <Charset></pre>| <pre>Accept: application/jsonAccept-Charset: UTF-8</pre> |-| Request body| <Empty>| <pre></pre>  |} === Global Search Response Message ==={| class="wikitable sortable" style="width: 100%;"|-! HTTP response part! Content! Example |-| Status Line| <pre>HTTP/1.1 <HTTP-Status-Code> <HTTP-Status-Message></pre>| <pre>HTTP/1.1 200 OK</pre> |-| Response headers|<pre>Content-Type: <Type>/<Subtype>; charset=<Charset>Location: <Location-URI>Link:X-Total-Count:</pre>|<pre>Content-Type: Content-Type: application/json; charset=UTF-8</pre> |-| [[#global_search_response_object|Response body]]| JSON object| <source lang="javascript">{ ... }</source>  |} ==== Global Search Response Message Body ===={| class="wikitable sortable" style="width: 100%;" id="global_search_response_object"|-|+ align="top" style="text-align:left;"|Global Search Response Object! Parameter name! Data type! Mandatory! Description! Valid content! [http://www.pcre.org/ PCRE]! Default value! Example  |-||ôbject|no| An object containing an array with one or more resource collection objects. See [[stoney_core:_Resellers_Resource_-_REST_API#reseller_collection_array_element_object | Reseller Collection Array Element Object]] for a concrete example.||||<source lang='javascript'>{ "resellers": { "resources": [ { "id": 4000000, "location": "https://api.example.com/v1/resellers/4000000", "isCompany": true, "isActive": true, "resellerName": "Example Reseller Ltd", "countryCode": "CH", "postalCode": "3012", "localityName": "Bern" }, { "id": 4000001, "location": "https://api.example.com/v1/resellers/4000001", "isCompany": true, "isActive": true, "resellerName": "Example Reseller No 2 Ltd", "countryCode": "CH", "postalCode": "8004", "localityName": "Zürich" } ], "location": "https://api.example.com/v1/resellers/?q=example" }, "customers": { "resources": [ { "id": 5000000, "location": "https://api.example.com/v1/customers/5000000", "isCompany": true, "isActive": true, "customerName": "Example Customer Ltd" "countryCode": "CH", "postalCode": "3012", "localityName": "Bern", "belongsToResellerID": 4000000 }, { "id": 5000001, "location": "https://api.example.com/v1/customers/5000001", "isCompany": false, "isActive": true, "customerName": "Peter Example" "countryCode": "CH", "postalCode": "3012", "localityName": "Bern", "belongsToResellerID": 4000001 } ], "location": "https://api.example.com/v1/customers/?q=example" }, "people": { "resources": [ { "id": 6000000, "location": "https://api.example.com/v1/people/6000000", "isActive": true, "givenName": "Peter", "surname": "Example" "customerName": "Example Customer Ltd", "belongsToResellerID": 4000000, "belongsToCustomerID": 5000000 }, { "id": 6000001, "location": "https://api.example.com/v1/people/6000001", "isActive": true, "givenName": "Thomas", "surname": "Example" "customerName": "Example Customer Ltd", "belongsToResellerID": 4000000, "belongsToCustomerID": 5000000 }, ], "location": "https://api.example.com/v1/people/?q=example" }, ...}</source>  |-|[[stoney_core:_REST_API#Error_codes_and_responses|<code>error</code>]]|object|no|In case of a failure, an error object with the appropriate error messages will be returned. Refer to the [[stoney_core:_REST_API#Error_codes_and_responses|Error codes and response chapter]] for more informations.||||<source lang="javascript">error { /* ... */ }</source> |} == Global Search Response Object (stoney core: Resellers Resource) ==The logic is described on the [[stoney core: Search Resource Mapping (REST - LDAP)]] page under the chapter [[stoney_core:_Search_Resource_Mapping_(REST_-_LDAP)#Global_Search_Response_Object_.28stoney_core:_Resellers_Resource.29 | Global Search Response Object (stoney core: Resellers Resource)]]. Resource collection object for the stoney core: Resellers Resource.<source lang='javascript'> "resellers": { "resources": [ { "id": 4000000, "location": "https://api.example.com/v1/resellers/4000000", "isCompany": true, "isActive": true, "resellerName": "Example Reseller Ltd", "countryCode": "CH", "postalCode": "3012", "localityName": "Bern" }, { "id": 4000001, "location": "https://api.example.com/v1/resellers/4000001", "isCompany": true, "isActive": true, "resellerName": "Example Reseller No 2 Ltd", "countryCode": "CH", "postalCode": "8004", "localityName": "Zürich" } ], "location": "https://api.example.com/v1/resellers/?q=example" },</source> == Global Search Response Object (stoney core: Customers Resource) ==The logic is described on the [[stoney core: Search Resource Mapping (REST - LDAP)]] page under the chapter [[stoney_core:_Search_Resource_Mapping_(REST_-_LDAP)#Global_Search_Response_Object_.28stoney_core:_Customers_Resource.29 | Global Search Response Object (stoney core: Customers Resource)]]. Resource collection object for the stoney core: Customers Resource.<source lang='javascript'> "customers": { "resources": [ { "id": 5000000, "location": "https://api.example.com/v1/customers/5000000", "isCompany": true, "isActive": true, "customerName": "Example Customer Ltd" "countryCode": "CH", "postalCode": "3012", "localityName": "Bern", "belongsToResellerID": 4000000 }, { "id": 5000001, "location": "https://api.example.com/v1/customers/5000001", "isCompany": false, "isActive": true, "customerName": "Peter Example" "countryCode": "CH", "postalCode": "3012", "localityName": "Bern", "belongsToResellerID": 4000001 } ], "location": "https://api.example.com/v1/customers/?q=example" },</source> == Global Search Response Object (stoney core: People Resource) ==The logic is described on the [[stoney core: Search Resource Mapping (REST - LDAP)]] page under the chapter [[stoney_core:_Search_Resource_Mapping_(REST_-_LDAP)#Global_Search_Response_Object_.28stoney_core:_People_Resource.29 | Global Search Response Object (stoney core: People Resource)]]. Resource collection object for the stoney core: People Resource.<source lang='javascript'> "people": { "resources": [ { "id": 6000000, "location": "https://api.example.com/v1/people/6000000", "isActive": true, "givenName": "Peter", "surname": "Example" "customerName": "Example Customer Ltd", "belongsToResellerID": 4000000, "belongsToCustomerID": 5000000 }, { "id": 6000001, "location": "https://api.example.com/v1/people/6000001", "isActive": true, "givenName": "Thomas", "surname": "Example" "customerName": "Example Customer Ltd", "belongsToResellerID": 4000000, "belongsToCustomerID": 5000000 }, ], "location": "https://api.example.com/v1/people/?q=example" },</source>  [[Category: REST API]][[Category:stoney core]]
SLB, editor, reviewer
3,368
edits