Importing ElasticSearch into Aurelia

有些话、适合烂在心里 提交于 2019-12-06 16:07:27

Here are special instructions to use elasticsearch.js in the browser . They say that:

  • versions for the browser are currently experimental.
  • they suggest to install it with bower using:

    bower install elasticsearch

Hope it helps...

Try to install it from github

jspm install elasticsearch-js=github:elastic/elasticsearch-js

Then you can use jquery module like:

import 'bootstrap'; // installed by default in aurelia-skeleton
import 'elasticsearch-js/src/elasticsearch.jquery';
let client = new $.es.Client({
   hosts: 'localhost:9200';
});

or build own Client like here https://github.com/elastic/elasticsearch-js/blob/master/src/elasticsearch.jquery.js

import es from 'elasticsearch-js';
//import es from 'elasticsearch-js/src/elasticsearch';

let config = {}

// Notice that you need to provide config.defer function if you build it yourself
// http://bluebirdjs.com/docs/api/deferred-migration.html

function defer() {
  var resolve, reject;
  var promise = new Promise(function() {
    resolve = arguments[0];
    reject = arguments[1];
  });
  return {
    resolve: resolve,
    reject: reject,
    promise: promise
  };
}

config.defer = defer;
config.hosts = 'localhost:9200';

let client = new es.Client(config)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!