elasticsearch逃避特殊人物

时间:2015-03-19 06:19:28

标签: elasticsearch

我正在运行以下查询

GET myindex/my_type/_search
{
  "query": {
    "query_string": {
      "default_field": "campaign_new",
      "query": "(firtPart - Second Third)"
    }
  }
}

我正在

{
   "took": 1,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 0,
      "max_score": null,
      "hits": []
   }
}

但是,如果我执行match_all搜索,则此广告系列具有值,但此查询未提取该值。我怀疑这可能是由于逃避问题所致。但是当我尝试firtPart \- Second\ Third时,它在Sense中显示错误。

1 个答案:

答案 0 :(得分:1)

你需要逃避两次爆炸。我假设您正在尝试进行完全匹配,因此您只需要将查询包装在双引号中,这也需要进行转义(引号只需要转义一次)。

{
    "query": {
        "query_string": {
            "default_field": "campaign_new",
            "query": "\"(firtPart - Second Third)\""
        }
    }
}