作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用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/
Laravel 7.0 版,我正在使用 cviebrock/eloquent-sluggable包裹。 我要的是放@作为用户名的前缀。 我在 User 模型中包含了 Sluggable trait 并
我正在尝试使用在这里找到的 Laravel 的 sluggable 包:https://github.com/cviebrock/eloquent-sluggable 当我保存一个模型(例如产品)时,
我是一名优秀的程序员,十分优秀!