-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_index.py
More file actions
54 lines (46 loc) · 1.04 KB
/
create_index.py
File metadata and controls
54 lines (46 loc) · 1.04 KB
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
48
49
50
51
52
53
54
import requests
import json
es_index_url = "http://localhost:9200/"
index_init_settings = {
"settings":{
"number_of_shards": 1,
"analysis": {
"char_filter": {
"replace": {
"type": "mapping",
"mappings": [
"&=> and "
]
}
},
"filter": {
"word_delimiter" : {
"type" : "word_delimiter",
"split_on_numerics" : False,
"split_on_case_change" : True,
"generate_word_parts" : True,
"generate_number_parts" : True,
"catenate_all" : True,
"preserve_original":True,
"catenate_numbers":True
}
},
"analyzer": {
"default": {
"type": "custom",
"char_filter": [
"html_strip",
"replace"
],
"tokenizer": "whitespace",
"filter": [
"lowercase",
"word_delimiter"
]
}
}
}
}
}
r = requests.put(es_index_url+"papers", headers={"Content-Type":"application/json"}, data=json.dumps(index_init_settings))
print(r.json())