pip install requests-aws4auth
- Add
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,ELASTICSEARCH_INDEX_NAME
andELASTICSEARCH_HOST
variables to your environment - Import the variables to your settings file
- Add the
WAGTAILSEARCH_BACKENDS
configuration to your settings file
Last active
October 14, 2022 12:53
-
-
Save saevarom/e2ab1f746a42873b7081a865490f8008 to your computer and use it in GitHub Desktop.
Elasticsearch config for Icelandic in Wagtail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# production settings file | |
from elasticsearch import RequestsHttpConnection | |
from requests_aws4auth import AWS4Auth | |
# You will need to import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ELASTICSEARCH_INDEX_NAME and ELASTICSEARCH_HOST from your environment | |
# You will also need to allow connections from your server to the elasticsearch instance in AWS | |
WAGTAILSEARCH_BACKENDS = { | |
'default': { | |
'BACKEND': 'wagtail.search.backends.elasticsearch6', | |
'INDEX': ELASTICSEARCH_INDEX_NAME, | |
'TIMEOUT': 120, | |
'HOSTS': [{ | |
'host': ELASTICSEARCH_HOST, | |
'port': 443, | |
'use_ssl': True, | |
'verify_certs': True, | |
'http_auth': AWS4Auth(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, 'eu-west-1', 'es'), | |
}], | |
'OPTIONS': { | |
'connection_class': RequestsHttpConnection, | |
}, | |
'INDEX_SETTINGS': { | |
'settings': { | |
'analysis': { | |
'analyzer': { | |
'ngram_analyzer': { | |
'type': 'custom', | |
'tokenizer': 'lowercase', | |
'filter': ['folding', 'ngram'] | |
}, | |
'edgengram_analyzer': { | |
'type': 'custom', | |
'tokenizer': 'lowercase', | |
'filter': ['folding', 'edgengram'] | |
} | |
}, | |
'tokenizer': { | |
'ngram_tokenizer': { | |
'type': 'nGram', | |
'min_gram': 3, | |
'max_gram': 15, | |
}, | |
'edgengram_tokenizer': { | |
'type': 'edgeNGram', | |
'min_gram': 2, | |
'max_gram': 15, | |
'side': 'front' | |
} | |
}, | |
'filter': { | |
'ngram': { | |
'type': 'nGram', | |
'min_gram': 3, | |
'max_gram': 15 | |
}, | |
'edgengram': { | |
'type': 'edgeNGram', | |
'min_gram': 1, | |
'max_gram': 15 | |
}, | |
'folding': { | |
'type': 'standard', | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment