Django-Haystack using Amazon Elasticsearch hosting with IAM credentials

前端 未结 2 1239
无人及你
无人及你 2021-02-09 11:03

I am hoping to use Amazon\'s Elasticsearch server to power a search of longtext fields in a Django database. However, I also don\'t want to expose this search to those who don\'

2条回答
  •  清酒与你
    2021-02-09 11:16

    You are one step from success, add connection_class to KWARGS and everything should work as expected.

    import elasticsearch
    
    HAYSTACK_CONNECTIONS = {
        'default': {
            'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
            'URL': [AWSHOST],
            'INDEX_NAME': 'haystack',
            'KWARGS': {
                'port': 443,
                'http_auth': awsauth,
                'use_ssl': True,
                'verify_certs': True,
                'connection_class': elasticsearch.RequestsHttpConnection,
            }
        },
    }
    

提交回复
热议问题