我运行以下PHP:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 4,
"max_score" : 1.0,
"hits" : [
{
"_index" : "my_index",
"_type" : "my_type",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"title" : "The quick brown fox"
}
},
{
"_index" : "my_index",
"_type" : "my_type",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"title" : "The quick brown fox jumps over the lazy dog"
}
},
{
"_index" : "my_index",
"_type" : "my_type",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"title" : "The quick brown fox jumps over the quick dog"
}
},
{
"_index" : "my_index",
"_type" : "my_type",
"_id" : "4",
"_score" : 1.0,
"_source" : {
"title" : "Brown fox brown dog"
}
}
]
}
}
我得到以下输出没有命中:
<ul>
<li>amethyst
<button class="up">Up</button>
<button class="down">Down</button>
<button class="remove">Remove</button>
</li>
<li>lavender
<button class="up">Up</button>
<button class="down">Down</button>
<button class="remove">Remove</button>
</li>
<li>plums
<button class="up">Up</button>
<button class="down">Down</button>
<button class="remove">Remove</button>
</li>
</ul>
但是如果之后我从命令行运行相同的空查询:
“d:\ Program Files \ curl \ bin \ curl.exe”-XPOST localhost:9200 / my_index / my_type / _search?pretty“-H”Content-Type:application / json“-d”{}“< / p>
我得到所有的点击量,我应该:
if(event.target.className == 'up') {
let li = event.target.parentNode;
var prevLi = li.previousElementSibling;
let ul = li.parentNode;
if (prevLi) {
ul.insertBefore(li, prevLi);
}
if(event.target.className == "down") {
var lid = event.target.parentNode;
var prevLiD = li.previousElementSibling;
let ul = li.parentNode
if (prevLiD) {
ul.insertBefore(li, prevLi);
}
有人可以告诉我我的最后一行PHP有什么问题吗?为什么没有命中?
答案 0 :(得分:1)
运行批量查询时,您可以看到已创建所有文档。但是,该索引尚未刷新,因此您在立即运行搜索时无法获得任何匹配。
您可以做的是在搜索之前调用刷新,如下所示:
echo curl_post('localhost:9200/my_index/_refresh', '{}');
或者只需在批量调用中添加refresh
参数,如下所示:
echo curl_post('localhost:9200/my_index/my_type/_bulk?pretty=true&refresh=true', ...
然后您可以正常发出搜索查询:
echo curl_post('localhost:9200/my_index/my_type/_search?pretty', '{}');