Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
drakerian committed Sep 30, 2014
0 parents commit 699a209
Show file tree
Hide file tree
Showing 25 changed files with 223,649 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Contributing to this connector

### Bugfixes
3 changes: 3 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.0.1 2014-09-30
----------------
- First version
19 changes: 19 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# loopback-connector-elastic-search

Basic Elasticsearch datasource connector for [Loopback](http://strongloop.com/node-js/loopback/).

## Setting up Elasticsearch
- Download and install [Elasticsearch](http://www.elasticsearch.org)
- Goto /elasticsearch-path/bin$ and execute ./elasticsearch
- Optional install [head plugin](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-plugins.html)
- Open browser and goto default url: http://localhost:9200/
- To use head plugin goto: _http://localhost:9200/_plugin/head/_
- If all is ok then the result is some this:<br>


{
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"
}

## Populate for demo Elasticsearch
Run in terminal:<br>

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


## Setting up Loopback
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

## Configuring elastic connector
Edit **datasources.json** and set:

[ConnectorEntry] : {
"host": [127.0.0.1],
"port": [9200],
"name": [Name],
"connector": "elasticsearch",
...
"log": "trace",
"defaultSize": [Rows],
"index": [IndexName],
"type": [TypeName]
}

Required:
---------
- **Host:** Elasticsearch engine host address.
- **Port:** Elasticsearch engine port.
- **Name:** Connector name.
- **Connector:** Elasticsearch driver.

Optional:
---------
- **Log:** logging option.
- **DefaultSize:** Rows to return per page.
- **Index:** Search engine specific index.
- **Type:** Search engine specific type.

## Run example
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, use for example in GET method:

{"q" : "friends, romans, countrymen"}

## Release notes

* First beta version
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TODO
- Add unit tests.
- Finish CRUD operations.
13 changes: 13 additions & 0 deletions examples/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions examples/.jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/client/
/node_modules/
21 changes: 21 additions & 0 deletions examples/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"indent": 2,
"latedef": "nofunc",
"newcap": true,
"nonew": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": false,
"trailing": true,
"sub": true,
"maxlen": 80
}
16 changes: 16 additions & 0 deletions examples/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.idea
.project
*.sublime-*
.DS_Store
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.swp
*.swo
node_modules
coverage
*.tgz
*.xml
3 changes: 3 additions & 0 deletions examples/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Client

This is the place for your application front-end files.
3 changes: 3 additions & 0 deletions examples/common/models/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (Entry) {

};
29 changes: 29 additions & 0 deletions examples/common/models/entry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "entry",
"plural": "entries",
"properties": {
"line_id": {
"type": "number"
},
"play_name": {
"type": "string"
},
"speech_number": {
"type": "number"
},
"line_number": {
"type": "string",
"required": true
},
"speaker": {
"type": "string"
},
"text_entry": {
"type": "string"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
Loading

0 comments on commit 699a209

Please sign in to comment.