-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.txt
210 lines (185 loc) · 4.06 KB
/
script.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Start filebeat with debug on processors
# ./filebeat.sh processors
### Step 1
# Step 1-1: Search for index documents
GET banotest/_search?track_total_hits=true
# Step 1-2: Add CSV
# "field": "message",
# "target_fields": [ "_id", "address.number", "address.street_name", "address.zipcode", "address.city", "source", "location.lat", "location.lon" ]
# Step 1-3: Add Remove Processor
# "field": [ "@timestamp", "input", "ecs", "host", "agent", "message" ]
# Step 1-4: Add Convert lat/lon to float
# "field": "location.lat",
# "type": "float"
# "field": "location.lon",
# "type": "float"
# Step 1-5: Remove banotest index and launch with more data
DELETE banotest
# head bano-data/bano-95.csv | ./curl_json.sh
GET banotest/_search?track_total_hits=true
### Step 2
# Step 2-1: Search
GET banotest/_search?track_total_hits=true
GET banotest/_search?track_total_hits=true
{
"query": {
"match": {
"address.street_name": "cormeilles"
}
}
}
GET banotest/_search?track_total_hits=true
{
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "1km",
"location": {
"lat": 49.09,
"lon": 1.98
}
}
}
}
}
}
# Step 2-2: What is the mapping?
GET banotest/_mapping
### Step 3
# Step 3-1: Create an index template (using Index Management)
# Step 3-2: Remove the existing banotest index (using Index Management)
# Step 3-3: Reindex and search again
GET banotest/_search?track_total_hits=true
{
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "1km",
"location": {
"lat": 49.09,
"lon": 1.98
}
}
}
}
}
}
### Step 4
# Step 4-1: Remove the existing banotest index
DELETE banotest
# Step 4-2: Use the log input pipeline (enable it in filebeat.yml)
# Step 4-3: Start filebeat and check how addresses are coming
# ./filebeat.sh
GET banotest/_count
# Step 4-4: show that we already have injected a dataset
GET bano-*/_count
# Step 4-5: open or create a Kibana Dashboard
### Step 5
# Step 5-1: search for addresses
GET bano-*/_search?track_total_hits=true
{
"size": 1,
"query": {
"multi_match": {
"query": "6 allée des myrtilles cergy",
"fields": [
"address.city",
"address.street_name",
"address.number"
],
"type": "most_fields"
}
}
}
# Step 5-2: search by geo point
GET bano-*/_search?track_total_hits=true
{
"size": 1,
"sort": [
{
"_geo_distance": {
"location": {
"lat": 49.0409,
"lon": 2.0178
}
}
}
]
}
# Step 5-3: search by points with some optimization
GET bano-*/_search?track_total_hits=true
{
"size": 1,
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "1km",
"location": {
"lat": 49.0409,
"lon": 2.0178
}
}
}
}
},
"sort": [
{
"_geo_distance": {
"location": {
"lat": 49.0409,
"lon": 2.0178
}
}
}
]
}
# Step 5-4: (Optional) search by points with some even more optimization
GET bano-95/_search?track_total_hits=true
{
"size": 1,
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "1km",
"location": {
"lat": 49.0409,
"lon": 2.0178
}
}
}
}
},
"sort": [
{
"_geo_distance": {
"location": {
"lat": 49.0409,
"lon": 2.0178
}
}
}
]
}
# Step 6-1: person dataset
GET person/_count
GET person/_search?track_total_hits=true
{
"query": {
"match": {
"address.city": "Cergy"
}
}
}
# Step 6-2: run logstash as it takes time
# ./logstash.sh
# Step 6-3: show the logstash pipeline and the query
# cat logstash-config/pipeline/bano.conf
# cat logstash-config/query/search-by-geo.json
# Step 6-4: check for new dataset
GET person-new/_count
GET person-new/_search?track_total_hits=true
# Step 6-5: create a map with person data compared to person-new data