0
votes

I'm trying to use Mirage to build my elastic search queries. I have started elastic search on localhost and when i do curl localhost:9210 on terminal, i get below details :

"name" : "RN48HFb",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "some number",
  "version" : {
    "number" : "5.6.0",
    "build_hash" : "something",
    "build_date" : "some date",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

So, I am trying to connect this elastic search cluster on mirage to build certain elastic search queries.

What appname and elastic search cluster i use to connect it on mirage?

I'm trying to put http://localhost:9210/ in URL section, but it doesn't work? what should be the appname : is it "RN48HFb"?

Please help I am new to this.

I have installed chrome extension for Mirage and the URL to mirage is :

https://github.com/appbaseio/mirage

chrome-extension://dcnlpfmnpoggchflmdnkgiepijgljoka/site/index.html

1

1 Answers

0
votes

sorry for the late response

You just need to update your ES config

Steps:

  1. Stop elasticsearch
  2. Update ES config: $DIR_ELASTIC/elasticsearch/elasticsearch.yml

Add this code:

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
http.cors.allow-headers: "Authorization, X-Requested-With, Content-Type, Content-Length"
http.cors.allow-methods: "OPTIONS, HEAD, GET, POST, PUT, DELETE"
  1. Start Elasticsearch

    You can Open console and try to make a request to be sure that mirage should work.

JS Code:

var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:9200/_search', true);
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('test:test'));
xhr.send('{"query":{"match_all":{}}}');

If it's response status is 200 then try with mirage.