简体   繁体   English

ElasticSearch查询结果是否已缓存?

[英]Are ElasticSearch query results cached?

I'm using ElasticSearch 2.3 and ASP.NET web application. 我正在使用ElasticSearch 2.3和ASP.NET Web应用程序。 I'm calling ElasticSearch through its REST API using C# HttpClient . 我正在使用C# HttpClient通过其REST API调用ElasticSearch。

I have a problem when trying to add new values to an array. 尝试将新值添加到数组时遇到问题。

Here's essentially the queries that I'm performing: 本质上是我正在执行的查询:

Step 1: Get note 步骤1:取得备忘

POST /notes/note/_search
{
  "query" : {
    "term" : { "_id" : 1 }
  }
}

There's only 1 note and the result shows that the note contains an empty array of attachments 只有一个便笺,结果显示该便笺包含一个空的附件数组

Step2: Update note attachments array 步骤2:更新注释附件数组

POST: /notes/note/1/_update
{
   "doc" : { 
      "Attachments" : [ "Test" ]
   }
}

Step3: Get note again 步骤3:再次取得记录

POST: /notes/note/_search
{
  "query" : {
    "term" : { "_id" : 1 }
  }
}

The result shows that the note still contains an empty Attachments array . 结果显示,笔记仍包含一个空的Attachments数组

However, when I Search/MatchAll from Kibana, I see that the Attachments array has been updated with the new item. 但是,当我从Kibana搜索/ MatchAll时,我看到Attachments数组已更新为新项目。 However, when running all those steps from ASP.NET, I'm not getting the updated document when immediately searching for it right after the update. 但是,从ASP.NET运行所有这些步骤时,在更新后立即搜索更新的文档时,我没有得到更新的文档。

Is this caused by some kind of caching ? 这是某种缓存引起的吗?

What must I do to get consistent state of the document after an update has been performed ? 执行更新后,我该怎么做才能使文档保持一致状态?

Any help appreciated! 任何帮助表示赞赏! Thanks 谢谢

What could be happening is that the refresh did not come by yet. 可能发生的是刷新尚未到来。 Than you are able to do a get by id, but the update is not available yet for search. 比您能够通过ID进行获取,但该更新尚不可用搜索。 So force a refresh before executing the search. 因此,在执行搜索之前强制刷新。 When inserting a lot of documents this does have a performance impact. 插入许多文档时,这确实会对性能产生影响。 But for testing you should be fine. 但是对于测试,您应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM