Note: This package is a fork of the easysearch:elasticsearch package with changes to make it compatible with Elasticsearch 2.1+.
This package adds an EasySearch.ElasticSearch
engine to EasySearch. EasySearch synchronizes documents to an index called
easysearch, with types based on the collection name.
// On Client and Server
let Players = new Meteor.Collection('players'),
PlayersIndex = new EasySearch.Index({
collection: Players,
fields: ['name'],
engine: new EasySearch.ElasticSearch({
body: () => { ... } // modify the body that's sent when searching
})
});
The client doesn't require any configuration if ElasticSearch runs locally on port 9200
.
The configuration options that can be passed to EasSearch.ElasticSearch
as an object are following.
- client: Object of client configuration (such as the
host
and so on) - fieldsToIndex: Array of document fields to index, by default all fields
- query(searchObject, options): Function that returns the query, by default a
fuzzy multi_match
query - sort(searchObject, options): Function that returns the sort parameter, by default the index
fields
- getElasticSearchDoc(doc, fields): Function that returns the document to index, fieldsToIndex by default
- body(body): Function that returns the ElasticSearch body to send when searching
To make changes to the mapping and other custom ElasticSearch actions you can use the exposed nodejs client on your index.
index.config.elasticSearchClient.putMapping({
// define custom mapping
});
# Install Elastic Search through brew.
brew install elasticsearch
# Start the service, runs on http://localhost:9200 by default.
elasticsearch -f -D es.config=/usr/local/opt/elasticsearch/config/elasticsearch.yml
cd /path/to/project
meteor add quadric:easy-elasticsearch