[ "filtere-6ren">
gpt4 book ai didi

php - 如何在Elasticsearch中突出显示我的结果?

转载 作者:行者123 更新时间:2023-12-03 00:33:36 25 4
gpt4 key购买 nike

我无法突出显示我的结果,查询的哪一部分是错误的?
用于Elasticsearch的PHPClient在执行时引发异常。

$query = [

"query" => [
"filtered" => [
"query" => [
"bool" => [
"should" => [
[
'query_string' => [
'fields' => [
'Title.title^4',
'Title.ngrams_front^2',
'Title.ngrams_back'
],
'defaultOperator' => 'or',
'query' => $paramsObj->q
]
],
[
'query_string' => [
'auto_generate_phrase_queries' => 0,
'enable_position_increments' => false,
'fields' => [
'Title.title',
'Address',
'keys'
],
'query' => $paramsObj->q,
'use_dis_max' => false,
'boost' => 2
]
],
[
'fuzzy' => [
'Title.title' => [
'value' => $paramsObj->q,
'boost' => 1,
'min_similarity' => 0.5,
'max_expansions' => 20,
'prefix_length' => 0
]
]
]
]
]
],
"filter" => $filters
]
],
"highlight" => [
"fields" => [
'Title.title' => [ "pre_tags" => "<em>", "post_tags" => "</em>" ]
]
]

];

首先,我尝试在过滤级别突出显示,然后在Google上搜索并发现我需要在过滤级别顶部的查询级别执行操作,所以我做到了,但仍然会引发异常。
Fatal error: Uncaught exception 'Guzzle\Http\Exception\ClientErrorResponseException' 

如果任何人都可以帮助,请帮助。

最佳答案

尝试这样的事情:

$query = array(
'query' => array(
'bool' => array(
'should' => array(
'fuzzy' => array(
'name' => array(
'value' => $serachstring,
'boost' => 1,
'min_similarity' => 0.5,
'max_expansions' => 20,
'prefix_length' => 0
),
),
// ...
)
),
),
'highlight' => array(
"pre_tags" => "<em>",
"post_tags" => "</em>",
'fields' => array(
'name' => (object) array()
)
),
);

关于php - 如何在Elasticsearch中突出显示我的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32052565/

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