Basic Elasticsearch datasource connector for Loopback.
If all is ok then the result is some this:
{ status: 200, name: "Arno Stark", version: { number: "1.3.2", build_hash: "dee175dbe2f254f3f26992f5d7591939aaefd12f", build_timestamp: "2014-08-13T14:29:30Z", build_snapshot: false, lucene_version: "4.9" }, tagline: "You Know, for Search" }
Run in terminal:
curl -XPUT http://localhost:9200/shakespeare -d '{
"mappings" : {
"_default_" : {
"properties" : {
"speaker" : {"type": "string", "index" : "not_analyzed" },
"play_name" : {"type": "string", "index" : "not_analyzed" },
"line_id" : { "type" : "integer" },
"speech_number" : { "type" : "integer" }
}
}
}
}';
Import data example to Elasticsearch:
cd examples/data
curl -XPUT localhost:9200/_bulk --data-binary @shakespeare.json
Install StrongLoop command line interface:
npm install -g strong-cli
Create project:
slc loopback:loopback
set project path and name
Attach datasource (see /server/datasources.json):
slc loopback:datasource test-elastic
select loopback-connector-elastic
Create model (see /examples/entry.json):
slc loopback:model entry
npm install loopback-connector-elastic-search --save
Edit datasources.json and set:
[ConnectorEntry] : {
"host": [127.0.0.1],
"port": [9200],
"name": [Name],
"connector": "elastic-search",
...
"log": "trace",
"defaultSize": [Rows],
"index": [IndexName],
"type": [TypeName]
}
Goto to examples folder and run:
npm install
Goto server folder and run:
node server.js
Open browse, and set in URL:
http://localhost:3000/explorer
To test a specific filter in GET method, use for example:
{"q" : "friends, romans, countrymen"}