使用es中遇到的问题

1.安装head插件时,记性npm install时提示错误:This failure might be due to the use of legacy binary “node”
原因:可能是因为安装了node而不是nodejs导致,使用如下指令安装sudo apt-get install nodejs-legacy后重新进行npm install即可正常

2.安装grunt插件:
sudo npm install -g grunt-cli

3.head插件无法连上集群

vim $ES_HOME$/config/elasticsearch.yml
# 增加如下字段
http.cors.enabled: true
http.cors.allow-origin: "*"

4.查询时显示:no [query] registered for [filtered]
查询语句:

{
    "query" : {
        "filtered" : {
            "filter" : {
                "range" : {
                    "age" : { "gt" : 30 } <1> }
            },
            "query" : {
                "match" : {
                    "last_name" : "Smith" <2> }
            }
        }
    }
}

其中的filtered已经弃用,应该使用如下查询方法:

{
  "query": {
    "bool": {
      "filter": {
        "range": {
          "age": { "gt": 20 } }
      },
      "must": {
        "match": {
          "last_name": "Smith" }
      }
    }
  }
}

5.进行统计的时候使用如下语句报错:

{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}
报错:
"root_cause": [

    {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
    }

]

原因:
Fielddata can consume a lot of heap space, especially when loading high cardinality text fields. Once fielddata has been loaded into the heap, it remains there for the lifetime of the segment.
(fielddata会消耗大量的栈内存,尤其在进行加载文本的时候,所以一单fielddata完成了加载,就会一直存在。)
Also, loading fielddata is an expensive process which can cause users to experience latency hits. This is why fielddata is disabled by default.
(同时,加载fielddata的过程中可能造成延迟命中,所以fielddata默认是关闭的。)
参考如下Doc

解决方法:
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests.keyword"
      }
    }
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值