Thursday, October 8, 2015

Elastic Search MongoDB Integration

Follow below steps to install elastic search, assuming mongoldb is already installed.


2) export ES_HOME=/Users/samaraarkotti/Documents/elasticsearch-1.7.2  
3) $ES_HOME/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.7.1   (  https://github.com/elastic/elasticsearch-mapper-attachments )
4) $ES_HOME/bin/plugin -install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9 ( https://github.com/richardwilly98/elasticsearch-river-mongodb/ )
5) $ES_HOME/bin/plugin --install mobz/elasticsearch-head
6) $ES_HOME/bin/plugin -i elasticsearch/marvel/latest
7) start elastic search bin/elasticsearch

Optional Plugin to install 

$ES_HOME/bin/plugin --install lukas-vlcek/bigdesk ( To access Inquisitor, open http://localhost:9200/_plugin/bigdesk)
$ES_HOME/bin/plugin -install polyfractal/elasticsearch-inquisitor   ( To access Inquisitor, open http://localhost:9200/_plugin/inquisitor/

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{"type": "mongodb","mongodb": {"db": "analytics","collection": "Article"},"index": {"name": "articleindex","type": "article"}}'
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{"type": "mongodb","mongodb": {"db": "analytics","collection": "ViewsAndRatingDetails"},"index": {"name": "viewindex","type": "views"}}'



-- DELETE Plugins using curl or directly on web both articleindex and _river , once done , run above curl command to index again .


Reference 



--- if getting any error's converting your standalone mongodb to replicaset , follow below steps
1)start the server in your usual way (single instance)
2)connect to the instance with a similar command : ./mongo --port 27017
3)look at your databases : show dbs
4)if there is a db called local, connect to it:  use local
drop that database : db.dropDatabase()



--- if you are getting error saying _mongodb RIVER FAILED to start ,
1) Then delete the _river plugin ( curl -XDELETE 'http://localhost:9200/_river/mongodb' )
2) shutdown ES and restart


-- disable dynamic mapping  -- NOT WORKING

curl -XDELETE localhost:9200/articleindex    --- First delete the index
curl -XPUT localhost:9200/articleindex -d '{"index.mapper.dynamic": false}'

--added below in elasticsearch.yml under config folder 
you will also need to configure elastic search to accept requests from the browser using CORS ( cross origin site scripting). To enable CORS, add the following to elasticsearch's config file. Usually, this file is located near the elasticsearch  at config/elasticsearch.yml

http.cors:
  enabled: true
  allow-origin: /https?:\/\/localhost(:[0-9]+)?/
  
  

  
  
  

Create ElasticSearch cluster on single machine

I wanted to figure out how to create a multi-node ElasticSearch cluster on single machine. So i followed these instructions First i did...