ElasticSearch错误请求

时间:2018-08-13 06:19:49

标签: elasticsearch

我正在使用Elasticsearch版本6.3.1。我正在使用查询更新来更新我的文档。有一些条件。这是update_by_query示例:

POST test/_update_by_query
    "script": {
        "source": "ctx._source.title = params.title;",
        "params": {
            "title": "demo"
        }

    },
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "_id": "123"
                }
            }]
        }
    }
 }

,但是elasticsearch给我的错误是:“错误请求”。 我无法重现此问题。请让我知道此问题的确切原因,以便为我找到相同的解决方案。

1 个答案:

答案 0 :(得分:0)

存在与括号关闭有关的问题,请尝试以下查询

checkCondition(){
      //Should be executed after one of these Subscription has fired
    if(isConfirmed){
       //keep on executing
    }
    else{ 
       //stopEvent
       event.preventDefault();
    }
}


const confirmDialogSubscription:Subscription = 
  this.dialogRef.componentInstance.onConfirm.subscribe(() => {
  this.dialogRef.close();
  isConfirmed = true;
  this.checkCondition()
});

const closeDialogSubscription = 
  this.dialogRef.componentInstance.onClose.subscribe(() => {
  this.dialogRef.close();
  isConfirmed = false;
  this.checkCondition()

});

相当于下面的curl命令

POST test/_update_by_query
{
  "script": {
    "source": "ctx._source.title = params.title",
    "params": {
      "title": "demo"
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "_id": "123"
          }
        }
      ]
    }
  }
}