繁体   English   中英

ElasticSearch索引文档在现有索引上失败

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM