-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.py
47 lines (44 loc) · 1.26 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from elasticsearch import Elasticsearch
es = Elasticsearch()
configuration = {
'settings': {
'analysis': {
'filter': {
'desc_ngram': {
'type': 'nGram',
'min_gram': 3,
'max_gram': 8
}
},
'analyzer': {
'index_ngram': {
'type': 'custom',
'tokenizer': 'keyword',
'filter': [ 'desc_ngram', 'lowercase' ]
},
'search_ngram': {
'type': 'custom',
'tokenizer': 'keyword',
'filter': [ 'lowercase', 'desc_ngram' ]
}
}
}
},
'mappings': {
'translates': {
'properties': {
'word_en': {
'type': 'string',
'analyzer': 'index_ngram',
'search_analyzer': 'search_ngram'
},
'word_ru': {
'type': 'string',
'analyzer': 'index_ngram',
'search_analyzer': 'search_ngram'
}
}
},
}
}
es.indices.create(index='languages', body=configuration)