gpt4 book ai didi

php - 在cviebrock/laravel-elasticsearch中设置elasticsearch映射

转载 作者:行者123 更新时间:2023-12-02 22:35:36 25 4
gpt4 key购买 nike

我尝试使用https://github.com/cviebrock/laravel-elasticsearch设置我的elasticsearch文档,但无法为我的某些字段-(Elasticsearch doc)设置fielddata = true

我已经尝试过这种方式:

$elasticSearch = ClientBuilder::create()->build();
$elasticSearch->index([
'body' => [
'testField' => 'abc'
],
"mappings" => [
'_doc' => [
"properties" => [
'testField' => [
"type" => "text",
"fielddata" => true
]
]
]
],
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
]);

最佳答案

我通过使用putMapping()方法解决了此问题。这种方法使我可以定义映射。

//put mapping
$elasticSearch->indices()->putMapping([
'index' => 'book',
'type' => 'books',
'body' => [
"properties" => [
'name' => [
"type" => "text",
"fielddata" => true
],
'author_name' => [
"type" => "text",
"fielddata" => true
]
]
]
]);

关于php - 在cviebrock/laravel-elasticsearch中设置elasticsearch映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54967726/

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