[英]ElasticSearch Index a Document fails on existing index
I am using ES php library. 我正在使用ES php库。 Here is what i have tried...
这是我尝试过的...
$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);
It returns success. 它返回成功。
Now when i try to index a document... 现在,当我尝试索引文档时...
$params = [
'index' => 'tasks',
'type' => 'all',
'id' => 'some_id',
'body' => [ 'task' => 'some test', 'to' => 'name', 'category' => 1]
];
$response = $client->index($params);
This throws error and does not work, however it works If i try this without creating index and mapping first. 这会引发错误并且不起作用,但是如果我在不先创建索引和映射的情况下尝试此操作,它将起作用。
Please suggest. 请提出建议。 Thanks
谢谢
It's wrong to define analyzer in a field of type 'integer'. 在“整数”类型的字段中定义分析器是错误的。
Trying to create this mapping through Elasticsearch-PHP gives me a bad request: 试图通过Elasticsearch-PHP创建此映射给我一个错误的请求:
... "reason":"Mapping definition for [category] has unsupported parameters: [analyzer : keyword]"}},"status":400}
Trying to create this mapping directly via PUT to ES gives me same error 尝试直接通过PUT到ES创建此映射会给我同样的错误
I'm using ES version 2.2.0 and Elasticsearch-PHP 2.0 我正在使用ES版本2.2.0和Elasticsearch-PHP 2.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.