elasticsearch,Node.js,Express,elasticsearch" /> elasticsearch,Node.js,Express,elasticsearch" />

Node.js 如何在Elasticsearch 5.0中绕过有效负载

Node.js 如何在Elasticsearch 5.0中绕过有效负载,node.js,express,elasticsearch,Node.js,Express,elasticsearch,我正在将旧的Elasticsearch集群升级到Elasticsearch 5.0 我注意到他们从Elasticsearch 5.0中删除了有效负载,这使我无法成功升级Elasticsearch 我意识到,有效负载在我的代码中多次出现。以下是我的代码片段,其中包括有效负载 elasticClient.index({ index: "users", type: "user", id: username, body: { name_suggest: { input

我正在将旧的Elasticsearch集群升级到Elasticsearch 5.0

我注意到他们从Elasticsearch 5.0中删除了
有效负载
,这使我无法成功升级Elasticsearch

我意识到,
有效负载
在我的代码中多次出现。以下是我的代码片段,其中包括
有效负载

elasticClient.index({
  index: "users",
  type: "user",
  id: username,
  body: {
    name_suggest: {
      input: displayname
      payload: { "user_id": username }
    }
  }
}, function(error) {
  console.log(error);
});
我使用React.js(JSX)和Express.js在下面的代码段中显示搜索结果

return (
  <ul id="searchValue" key="wow">
    {result.options[0] ? <a href={"users/" + result.options[0].payload.user_id}><li style={{display: this.state.searchResults}} key={ result.options[0].payload.user_id }>{ result.options[0].text}</li></a> : null}
    {result.options[1] ? <a href={"users/" + result.options[1].payload.user_id}><li style={{display: this.state.searchResults}} key={ result.options[1].payload.user_id }>{ result.options[1].text}</li></a> : null}
    {result.options[2] ? <a href={"users/" + result.options[2].payload.user_id}><li style={{display: this.state.searchResults}} key={ result.options[2].payload.user_id}>{ result.options[2].text}</li></a> : null}
    {result.options[3] ? <a href={"users/" + result.options[3].payload.user_id}><li style={{display: this.state.searchResults}} key={ result.options[3].payload.user_id}>{ result.options[3].text}</li></a> : null}
    {result.options[4] ? <a href={"users/" + result.options[4].payload.user_id}><li style={{display: this.state.searchResults}} key={ result.options[4].payload.user_id}>{ result.options[4].text}</li></a> : null}
  </ul>
)
返回(
    {result.options[0]?:null} {result.options[1]?:null} {result.options[2]?:null} {result.options[3]?:null} {result.options[4]?:null}
)
如您所见,我多次使用
payload


在Elasticsearch 5.0中,我需要如何更新代码以使其在没有
有效负载的情况下工作?

我必须删除带有
有效负载的每一行,并按照说明使用
\u source

例如:

return (
  <ul id="searchValue" key="wow">
    {result.options[0] ? <a href={"users/" + result.options[0]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[0]._source.name_suggest.input}>{ result.options[0].text}</li></a> : null}
    {result.options[1] ? <a href={"users/" + result.options[1]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[1]._source.name_suggest.input}>{ result.options[1].text}</li></a> : null}
    {result.options[2] ? <a href={"users/" + result.options[2]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[2]._source.name_suggest.input}>{ result.options[2].text}</li></a> : null}
    {result.options[3] ? <a href={"users/" + result.options[3]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[3]._source.name_suggest.input}>{ result.options[3].text}</li></a> : null}
    {result.options[4] ? <a href={"users/" + result.options[4]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[4]._source.name_suggest.input}>{ result.options[4].text}</li></a> : null}
  </ul>
)
返回(
    {result.options[0]?:null} {result.options[1]?:null} {result.options[2]?:null} {result.options[3]?:null} {result.options[4]?:null}
)
payload.user\u id
更改为
\u source.name\u suggest.input


我还删除了行
有效载荷:{“user\u id”:username}
,因为它在Elasticsearch 5.0中不是必需的。

我必须删除所有带有
有效载荷的行,并使用
\u source
,如前所述

例如:

return (
  <ul id="searchValue" key="wow">
    {result.options[0] ? <a href={"users/" + result.options[0]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[0]._source.name_suggest.input}>{ result.options[0].text}</li></a> : null}
    {result.options[1] ? <a href={"users/" + result.options[1]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[1]._source.name_suggest.input}>{ result.options[1].text}</li></a> : null}
    {result.options[2] ? <a href={"users/" + result.options[2]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[2]._source.name_suggest.input}>{ result.options[2].text}</li></a> : null}
    {result.options[3] ? <a href={"users/" + result.options[3]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[3]._source.name_suggest.input}>{ result.options[3].text}</li></a> : null}
    {result.options[4] ? <a href={"users/" + result.options[4]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[4]._source.name_suggest.input}>{ result.options[4].text}</li></a> : null}
  </ul>
)
返回(
    {result.options[0]?:null} {result.options[1]?:null} {result.options[2]?:null} {result.options[3]?:null} {result.options[4]?:null}
)
payload.user\u id
更改为
\u source.name\u suggest.input

我还删除了行
payload:{“user_id”:username}
,因为它在Elasticsearch 5.0中不是必需的