0.0.7 • Published 9 years ago

roadiejs-elastic v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

roadiejs-elastic

A plugin for RoadieJS

Integrates RoadieJS with Elasticsearch's search, complete and aggregation capabilities.

Contents

API

searchAll (GET)

Searches all RoadieJS indexes using parameters supplied in the request.

Request

GET /search

Example http://localhost:3010/search?q=Walter&from=11&size=10&category=admin

Query parameters

ParameterNotes
qQuery string to filter results. Supports Elasticsearch's query_string syntax.
fromZero-indexed offset for use when paginating results
sizeMaximum number of documents returned
sortUse to sort results. Some options: Give just a field name, and documents will be ordered by that field, ascending. Suffix with a :desc to make the order descending. Also supports comma delimitation for multi-field sorts.
refreshEither true or false (the default). If refresh is true the index will be refreshed (e.g. wait until all outstanding document changes are resolved) before attempting the search. Useful if results are required instantly after a document has been updated.
categoryRestrict the search to within the specified category
subCategoryRestrict the search to within the specified sub-category
Response

Status 200

  • The body of the response mirrors that of the results from the underlying Elasticsearch query.

searchAll (POST)

Searches all RoadieJS indexes, like searchAll (GET). except Elasticsearch DSL should be provided in the request body.

Request

POST /search

{
  refresh: true,
  query: {
    range: {
      "squareMiles": {
        "gt": 150000
      }
    }
  }
}
  • The body of the request should be valid Elasticsearch DSL.
Response

Status 200

  • The body of the response mirrors that of the results from the underlying Elasticsearch query.

searchIndex (GET)

Searches the specified index, using parameters supplied in the request.

Request

GET /search/:indexName

ParameterNotes
indexNameThe name of a valid Elasticsearch index (without the roadiejs. prefix)

Query parameters

ParameterNotes
qQuery string to filter results. Supports Elasticsearch's query_string syntax.
fromZero-indexed offset for use when paginating results
sizeMaximum number of documents returned
sortUse to sort results. Some options: Give just a field name, and documents will be ordered by that field, ascending. Suffix with a :desc to make the order descending. Also supports comma delimitation for multi-field sorts.
refreshEither true or false (the default). If refresh is true the index will be refreshed (e.g. wait until all outstanding document changes are resolved) before attempting the search. Useful if results are required instantly after a document has been updated.
categoryRestrict the search to within the specified category
subCategoryRestrict the search to within the specified sub-category
Response

Status 200

  • The body of the response mirrors that of the results from the underlying Elasticsearch query.

searchIndex (POST)

Searches the specified index, like searchIndex (GET). except Elasticsearch DSL should be provided in the request body.

Request

POST /search/:indexName

ParameterNotes
indexNameThe name of a valid Elasticsearch index (without the roadiejs. prefix)
{
  refresh: true,
  query: {
    range: {
      "squareMiles": {
        "gt": 150000
      }
    }
  }
}
  • The body of the request should be valid Elasticsearch DSL.
Response

Status 200

  • The body of the response mirrors that of the results from the underlying Elasticsearch query.

findById

Returns a document with the matching id, from the specified index.

Request

GET /search/:indexName/:id

ParameterNotes
indexNameThe name of a valid Elasticsearch index (without the roadiejs. prefix)
idThe id of an Elasticsearch document
Response

Status 200

  • The body of the response mirrors that of the results from the underlying Elasticsearch query.

complete

Delivers typeahead functionality based on Elasticsearch's Completion Suggester

Request

GET /complete/:indexName

ParameterNotes
indexNameThe name of a valid Elasticsearch index (without the roadiejs. prefix)

Query parameters

ParameterNotes
textThe as-you-type text from which will be sent to Elasticsearch's Completion Suggester.
Response

Status 200

Activities

populateLookups

Used to derive a user-facing label from a Elasticsearch document, based on a stored id value.

Example
{
  "element": "activity",
  "id": "populateLookups",
  "path": "maintainTeacher",
  "config": {
    "activityType": "populateLookups",
    "config": {
      "targetActivityId": "showTeacherUi",
      "lookups": [
        {
          "field": "department",
          "schema": "departments"
        }
      ]
    }
  }
}
Config
NameTypeNotes
targetActivityIdstringThe id of an activity within the current flow, that is storing the id value to lookup in Elasticsearch.
fieldstringIdentifies which field stores the id value in the target activities data object.
schemastringThe 'child' schema defined in the blueprint, which should contain the id identified by field

Data tasks

elasticDocSync

Used to synchronise create/update/delete operations on schema documents with their counterparts in an Elasticsearch index.

  • There's no need to define this task explicitly, it's added automatically as part of the schema element initialisation.

elasticPurge

Used to synchronise purges of schemas with the removal of documents in the associated Elasticsearch index.

  • There's no need to define this task explicitly, it's added automatically as part of the schema element initialisation.

License

MIT

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago