REQUEST A LIVE DEMO

Index Resource

Path : /v1/index/{index name?}

Description:

The index resource is used to create and delete indicies within a search engine. When a search engine is created, one index is automatically created for its use. You can optionally create more, if you need to segregate your data in application-specific ways.

This resource can be used to get a list of indices contained with the search engine, and create and manage indices. Deleting an index will remove all associated data from the search engine. DragonGlass will create an index named “default” if you attempt to use the document APIs before explicitly creating an index.

Parameters:

Name Value Description
name String The display name of the new index
default_search_fields String The list of fields to search against if not explicitly stated in query
freshness_policy String The freshness policy to apply to this index. The default policy is “near real time”, which means that documents will be available for search within 30 seconds. Valid policies are “real time” (1 second delay), “near real time” (30 second delay), “bulk load” (1 minute delay).

Code Sample:

curl -X GET http://api.dragonglass.me/v1/index --user username:password curl -X POST http://api.dragonglass.me/v1/index --user username:password -d ‘{“name”: “New Index”, “default_search_fields”: [“_all”]} curl -X PUT http://api.dragonglass.me/v1/index/new-index --user username:password -d ‘{“name”: “Changed Index Name”, “default_search_fields”: [“some_field”]} curl -X DELETE http://api.dragonglass.me/v1/index/new-index/index --user username:password

Success response code:

  • 200 for GET, PUT, DELETE.
  • 201 WILL be returned for POST operations (if successful) with the new resource’s URL specified in the Location header.
  • POST and DELETE do not return a response body.

Response:

{ "indexes": [ ...{ "links": [ …listofHATEOASurls… ], "name": “new-index", “default_search_fields”: [“_all”], "real_indexes": "default", "types": [] } ... ] }

Error response code:

Error Code Reason
401 You did not provide authorization credentials
403 The credentials you provided were incorrect or not recognized