简体   繁体   English

使用映射创建新的ElasticSearch索引

[英]Creating a new ElasticSearch index with mapping

I am able to do the following to create a new ES index: 我可以执行以下操作来创建新的ES索引:

>>> es.indices.create(index = 'example_index')
{u'index': u'example_index', u'acknowledged': True, u'shards_acknowledged': True}

However, if I add any sort of mapping I get an unknown error. 但是,如果添加任何类型的映射,都会出现未知错误。 For example: 例如:

request_body = {
    'mappings': {
        '_doc': {
            'properties': {
                'address': {'index': 'not_analyzed', 'type': 'string'},
                'some_PK': {'index': 'not_analyzed', 'type': 'string'},
            }}}
}
es.indices.create(index = 'example_index', body=request_body)

> TransportError: <unprintable TransportError object>

How would I create a proper index with a pre-defined mapping here? 如何在此处使用预定义的映射创建适当的索引? And why does it give such an unhelpful error message? 为什么会给出这样无益的错误消息?

While I was only trying to connect to an external ES server, and did not think I needed it installed locally, installing this locally and making sure that Java was installed fixed the above issue. 虽然我只是尝试连接到外部ES服务器,但我认为我不需要在本地安装它,但是在本地安装并确保已安装Java可以解决上述问题。

It seems that the Elasticsearch module may need both java and ElasticSearch installed locally for some of the calls it does, even if not using a local ElasticSearch cluster. 看来,即使不使用本地ElasticSearch集群, Elasticsearch模块可能也需要在本地安装javaElasticSearch进行某些调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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