gpt4 book ai didi

real-time - 刷新 Elasticsearch 索引/实时搜索

转载 作者:行者123 更新时间:2023-12-02 22:16:21 26 4
gpt4 key购买 nike

我正在为 ElasticSearch 数据源编写单元测试,但是,我得到的结果好坏参半。问题是 match_all 查询没有找到我提交的记录,但是,当我以相同的顺序使用 CURL 手动运行命令时,单元测试确实能够找到记录。

我认为可能索引没有刷新,所以,我在提交记录后开始运行“刷新”api命令,但是,这也没有用。这是我的命令列表 - 如果有人对如何确保这些命令有效(即使它们立即连续运行)有任何建议,这将很有帮助。

命令单元测试运行:

curl -XGET 'http://localhost:9200/test_index/_mapping'

curl -XDELETE 'http://localhost:9200/test_index/test_models'

curl -XPOST 'http://localhost:9200/test_index/test_models/_refresh' -d '{}'

curl -XPUT 'http://localhost:9200/test_index/test_models/_mapping' -d '{"test_models":{"properties":{"TestModel":{"properties":{"id":{"type":"string","index":"not_analyzed"},"string":{"type":"string"},"created":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"},"modified":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}},"type":"object"}}}}'

curl -XPOST 'http://localhost:9200/test_index/test_models/_bulk' -d '{"index":{"_index":"test_index","_type":"test_models","_id":"test-model"}}
{"TestModel":{"id":"test-model","string":"Analyzed for terms","created":"2012-01-01 00:00:00","modified":"2012-02-01 00:00:00"}}
'

curl -XPOST 'http://localhost:9200/test_index/test_models/_refresh' -d '{}'

curl -XGET 'http://localhost:9200/test_index/_mapping'

curl -XGET 'http://localhost:9200/test_index/test_models/_search' -d '{"query":{"match_all":{}},"size":10}'

这个问题也已经发布到( super 棒的)ElasticSearch 邮件列表:

https://groups.google.com/forum/?fromgroups#!topic/elasticsearch/Nxv0XpLDY4k

-DK

最佳答案

问题出在 _refresh 命令上。

不能刷新类型,只能刷新索引。我将刷新命令更改为:

curl -XPOST 'http://localhost:9200/test_index/_refresh'

现在已经修复了!

关于real-time - 刷新 Elasticsearch 索引/实时搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11593359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com