-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapping.py
More file actions
49 lines (42 loc) · 1.36 KB
/
Copy pathmapping.py
File metadata and controls
49 lines (42 loc) · 1.36 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
from elasticsearch import Elasticsearch
es = Elasticsearch(
[ {'host': 'localhost', 'port': 9200, "scheme": "http"}],
)
# Define the index settings and mappings
index_name = 'velo' # Replace with your desired index name
if es.indices.exists(index=index_name):
es.indices.delete(index=index_name)
create_index = {
"settings": {
"analysis": {
"analyzer": {
"payload_analyzer": {
"type": "custom",
"tokenizer":"whitespace",
}
}
}
},
"mappings": {
"properties": {
"number": {"type": "integer"},
"contractName": {"type": "keyword"},
"name": {"type": "text"},
"address": {"type": "text"},
"last_update": {"type": "date", "format": "yyyy-MM-dd HH:mm:ss||epoch_millis"},
"position": {
"type": "geo_point",
"fields": {
"latitude": {"type": "text"},
"longitude": {"type": "text"}
}
},
"bikes": {"type": "integer"},
"stands": {"type": "integer"},
"capacity": {"type": "integer"}
# Add more fields as needed
}
}
}
# create index with the settings & mappings above
es.indices.create(index="velo", body=create_index)