roadiejs-elastic
v0.0.7
Published
Elasticsearch capabilities in RoadieJS
Downloads
6
Readme
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
| Parameter | Notes
| ----- | ----
| q
| Query string to filter results. Supports Elasticsearch's query_string syntax.
| from
| Zero-indexed offset for use when paginating results
| size
| Maximum number of documents returned
| sort
| Use 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.
| refresh
| Either 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.
| category
| Restrict the search to within the specified category
| subCategory
| Restrict 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
| Parameter | Notes
| ----- | ----
| indexName
| The name of a valid Elasticsearch index (without the roadiejs.
prefix)
Query parameters
| Parameter | Notes
| ----- | ----
| q
| Query string to filter results. Supports Elasticsearch's query_string syntax.
| from
| Zero-indexed offset for use when paginating results
| size
| Maximum number of documents returned
| sort
| Use 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.
| refresh
| Either 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.
| category
| Restrict the search to within the specified category
| subCategory
| Restrict 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
| Parameter | Notes
| ----- | ----
| indexName
| The 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
| Parameter | Notes
| ----- | ----
| indexName
| The name of a valid Elasticsearch index (without the roadiejs.
prefix)
| id
| The 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
| Parameter | Notes
| ----- | ----
| indexName
| The name of a valid Elasticsearch index (without the roadiejs.
prefix)
Query parameters
| Parameter | Notes
| ----- | ----
| text
| The as-you-type text from which will be sent to Elasticsearch's Completion Suggester.
Response
Status 200
- The body of the response mirrors that of the results from Elasticsearch's Completion Suggester.
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
| Name | Type | Notes
| ------------ | -------| -----------
| targetActivityId
| string
| The id
of an activity within the current flow, that is storing the id
value to lookup in Elasticsearch.
| field
| string
| Identifies which field stores the id
value in the target activities data
object.
| schema
| string
| The '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.