我尝试使用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',
]);
答案 0 :(得分:0)
我通过使用putMapping()
方法解决了此问题。这种方法使我可以定义映射。
//put mapping
$elasticSearch->indices()->putMapping([
'index' => 'book',
'type' => 'books',
'body' => [
"properties" => [
'name' => [
"type" => "text",
"fielddata" => true
],
'author_name' => [
"type" => "text",
"fielddata" => true
]
]
]
]);