Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅突出显示查询_Php_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Php,elasticsearch" /> elasticsearch,Php,elasticsearch" />

Php 仅突出显示查询

Php 仅突出显示查询,php,elasticsearch,Php,elasticsearch,我正在使用php中的elasticsearch,并尝试使用如下突出显示我的参数: $params = [ 'index' => 'idx', 'type' => 'type', 'body' => [ 'query' => [ 'bool' => [ 'should' => [

我正在使用php中的elasticsearch,并尝试使用如下突出显示我的参数:

$params = [
     'index' => 'idx',
        'type' => 'type',
        'body' => [
            'query' => [
                'bool' => [
                    'should' => [
                           ['wildcard' => [
                            "identifier.contact.firstName" => '*' . $search . '*'
                        ]]
                     ]
                ]
            ],
            'sort' => [
                "id" => ["order" => "desc"]

            ],
            'highlight' => [
                'fields' => [
                    "identifier.contact.firstName" => new \stdClass()
                ],
            ]
        ],
因此,除了在我的
突出显示
字段中,它工作得非常好

<em> Nicolas </em> 

但一切都没有改变。我还尝试了片段大小和片段数量的几个值。我设法用一种改变高光的算法来处理这个问题,但我发现这很糟糕

我的配置:

 'body' => [
                'settings' => [
                    'number_of_shards' => 5,
                    'number_of_replicas' => 0,
                    'analysis' => [
                        'my_analyzer' => [
                            "tokenizer" => "my_tokenizer"
                        ],
                        "tokenizer" => [
                            "my_tokenizer" => [
                                "type"=> "ngram",
                                "min_gram" => 1,
                                "max_gram" => 10,
                                "token_char" => [
                                    "letter",
                                    "digit"
                                ]
                            ]
                        ]
                    ]
                ],

您可以显示索引配置?看起来您可以通过“空格”符号标记短语。我认为使用
ngram
tokenizer对你有帮助。@maximku好的,我阅读了关于ngram的文档并更新了我的配置文件,我添加了它,所以请检查你对它的看法设置
minu ngram
到2,因为在某些版本中,弹性体有bug:)@maximku它工作得很好,谢谢。添加一个答案,这样我就可以验证它,如果你不想,我会的
'highlight' => [
                'fragment_size' => 5,
                'number_of_fragments' => 5,
                'fragmenter' => "span",
                'fields' => [
                    "identifier.contact.firstName" => new \stdClass()
                ],
            ]
 ]
'highlight' => [
                'fields' => [
                    "identifier.contact.firstName" => [
                        "fragment_size" => 5,
                        "number_of_fragments" => 5,
                        "fragmenter" => "span"
                    ],
                ]
]
 'body' => [
                'settings' => [
                    'number_of_shards' => 5,
                    'number_of_replicas' => 0,
                    'analysis' => [
                        'my_analyzer' => [
                            "tokenizer" => "my_tokenizer"
                        ],
                        "tokenizer" => [
                            "my_tokenizer" => [
                                "type"=> "ngram",
                                "min_gram" => 1,
                                "max_gram" => 10,
                                "token_char" => [
                                    "letter",
                                    "digit"
                                ]
                            ]
                        ]
                    ]
                ],