一尘不染

如果在Elasticsearch查询中使用script_fields,则不再有_source

elasticsearch

我正在运行一个简单的查询,如下所示:

{
  "query": {
    "term": {
      "statuses": "active"
    }
  },
  "script_fields": {
    "test": {
      "script": "_source.name"
    }
  }
}

问题在于,一旦引入script_fields,我将不再获得_source结果。

我努力了:

{
  "fields": [
    "_all"
  ],
  "query": {
    "term": {
      "statuses": "active"
    }
  },
  "script_fields": {
    "email": {
      "script": "_source.name"
    }
  }
}

{
  "fields": [
    "*"
  ],
  "query": {
    "term": {
      "statuses": "active"
    }
  },
  "script_fields": {
    "email": {
      "script": "_source.name"
    }
  }
}

但是它们没有任何区别。_source除了之外,还有其他方法可以退货script_fields吗?


阅读 4140

收藏
2020-06-22

共1个答案

一尘不染

fields数组中,使其加载_source

{
  "stored_fields": [
    "_source"
  ],
  "query": {
    "term": {
      "statuses": "active"
    }
  },
  "script_fields": {
    "email": {
      "script": "_source.name"
    }
  }
}
2020-06-22