[英]ElasticSearch Index a Document fails on existing index
我正在使用ES php庫。 這是我嘗試過的...
$params = [
'index' => 'tasks',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 2
],
'mappings' => [
'all' => [
'_source' => [
'enabled' => true
],
'properties' => [
'task' => [
'type' => 'string',
'analyzer' => 'standard'
],
'to' => [
'type' => 'string',
'analyzer' => 'standard'
],
'category' => [
'type' => 'integer',
'analyzer' => 'keyword'
]
]
]
]
]
];
// Create the index with mappings and settings now
$response = $client->indices()->create($params);
它返回成功。
現在,當我嘗試索引文檔時...
$params = [
'index' => 'tasks',
'type' => 'all',
'id' => 'some_id',
'body' => [ 'task' => 'some test', 'to' => 'name', 'category' => 1]
];
$response = $client->index($params);
這會引發錯誤並且不起作用,但是如果我在不先創建索引和映射的情況下嘗試此操作,它將起作用。
請提出建議。 謝謝
在“整數”類型的字段中定義分析器是錯誤的。
試圖通過Elasticsearch-PHP創建此映射給我一個錯誤的請求:
... "reason":"Mapping definition for [category] has unsupported parameters: [analyzer : keyword]"}},"status":400}
嘗試直接通過PUT到ES創建此映射會給我同樣的錯誤
我正在使用ES版本2.2.0和Elasticsearch-PHP 2.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.