弹性搜索PHP搜索查询有什么问题?
我一直试图让下面的JSON在PHP数组中工作,但似乎没有得到任何成功 JSON如下所示:弹性搜索PHP搜索查询有什么问题?,php,
elasticsearch,Php,
elasticsearch,我一直试图让下面的JSON在PHP数组中工作,但似乎没有得到任何成功 JSON如下所示: { "query": { "filtered": { "query": { "query_string": { "query": "search" } } } }, "fields": [ "body", "title", "postDate", "user", "
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "search"
}
}
}
},
"fields": [
"body",
"title",
"postDate",
"user",
"name"
],
"from": 0,
"size": 50,
"sort": {
"_score": {
"order": "asc"
}
},
"explain": true
}
我创建的PHP是这样的:
$docs = $client->search([
'index' => 'blog',
'type' => 'posts',
'body' => [
'query' => [
'filtered' => [
'query' => [
'query_string' => [
'query' => $search_query
]
]
]
],
'fields' => [
'body',
'title',
'postDate',
'user',
'name'
],
'from' => 0,
'size' => 50,
'sort' => [
'_score' => [
'order' => 'asc'
]
]
]
]);
它返回一个响应,但并没有命中,即使它应该返回(在JSON请求的情况下也是如此)
这是怎么回事?根本不需要帖子类型。。。我不知怎么地认为是这样。我使用了一个名为ElasticHQ的工具来生成JSON,但我没有意识到它没有使用POST作为类型 改成
$docs = $client->search([
'index' => 'blog',
'body' => [
'query' => [
'filtered' => [
'query' => [
'query_string' => [
'query' => $search_query
]
]
]
],
'fields' => [
'body',
'title',
'postDate',
'user',
'name'
],
'from' => 0,
'size' => 50,
'sort' => [
'_score' => [
'order' => 'asc'
]
]
]
]);
职位类型根本不是必需的。。。我不知怎么地认为是这样。我使用了一个名为ElasticHQ的工具来生成JSON,但我没有意识到它没有使用POST作为类型 改成
$docs = $client->search([
'index' => 'blog',
'body' => [
'query' => [
'filtered' => [
'query' => [
'query_string' => [
'query' => $search_query
]
]
]
],
'fields' => [
'body',
'title',
'postDate',
'user',
'name'
],
'from' => 0,
'size' => 50,
'sort' => [
'_score' => [
'order' => 'asc'
]
]
]
]);
您能显示发送JSON查询时使用的URL吗?好的,我算出了。。职位类型根本不是必需的。。。我不知怎么地认为是这样。我使用了一个名为ElasticHQ的工具来生成JSON,但我没有意识到它没有使用POST作为类型。你能在发送JSON查询时显示你正在使用的URL吗?好的,我找到了。。职位类型根本不是必需的。。。我不知怎么地认为是这样。我使用了一个名为ElasticHQ的工具来生成JSON,我没有意识到它没有使用POST作为类型。几乎,明天我可以:)几乎,明天我可以:)