Elasticsearch Javascript浏览器客户端

时间:2016-03-19 17:11:18

标签: javascript browser elasticsearch

我正在尝试使用浏览器客户端

运行查询

http://jsfiddle.net/stnxx/27/

但是我得到了

Uncaught Error: Cannot find module './lib/client'e 
  @ elasticsearch.min.js:7(anonymous function) 
  @ elasticsearch.min.js:7d.19.vh 
  @ elasticsearch.min.js:10e 
  @ elasticsearch.min.js:7a 
  @ elasticsearch.min.js:7(anonymous function) 
  @ elasticsearch.min.js:7(anonymous function) 
  @ elasticsearch.min.js:20
(index):49 Uncaught ReferenceError: elasticsearch is not defined(anonymous function) 
  @ (index):49jQuery.event.dispatch 
  @ jquery-2.1.0.js:4371elemData.handle 
  @ jquery-2.1.0.js:4057

我错过了什么吗?

的Javascript

client = elasticsearch.Client({
    host: 'Valid elasticsearch url'
})

client.search({
    body: {
        query: {
            match_all: {}
        }
    }
}).then(
  function (body) {
    $('#results').html(JSON.stringify(body.hits))
  },

  function (error) {
    $('#results').html(JSON.stringify(error))
  }
)

1 个答案:

答案 0 :(得分:0)

你的jsfiddle例子中的

你在查询中有语法错误。

query: { "range": { "date": { "gte":"20160318T00:00:00-0800", "lte":"20160318T23:59:59-0800" } } }