0
我正在使用ES php库。这是我已经尝试过...ElasticSearch索引文档在现有索引上失败
$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);
这将引发错误和不工作,但它的工作原理,如果我尝试这种无需先创建索引和映射。
请建议。谢谢
如果我从类别中删除分析器,仍然会出现相同的错误。 – seoppc