Skip to content

Commit b8d6f0f

Browse files
author
Ivan Franchin
committed
project upgrade
- upgrade to spring-boot 2.7.3 - upgrade to springdoc-openapi 1.6.11; - improve products search; - update README.
1 parent c250be9 commit b8d6f0f

File tree

5 files changed

+91
-23
lines changed

5 files changed

+91
-23
lines changed

README.adoc

+17-13
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ docker-compose ps
6565

6666
=== Reindex
6767

68-
The script `./reindex.sh` is used to reindex from an index to another index. The default will reindex from `ecommerce.products.v1` to `ecommerce.products.v2`. The only difference between `elasticsearch/mapping-v1.json` (used by `ecommerce.products.v1`) to `elasticsearch/mapping-v2.json` (used by `ecommerce.products.v2`) is the `type` of the `reference` property. In the former is set `text` and in the latter, `keyword`.
68+
The script `./reindex.sh` is used to reindex an index to another. The default will reindex from `ecommerce.products.v1` to `ecommerce.products.v2`. The only difference between `elasticsearch/mapping-v1.json` (used by `ecommerce.products.v1`) to `elasticsearch/mapping-v2.json` (used by `ecommerce.products.v2`) is the `type` of the `reference` property. In the former, it is set the type `text` and, in the latter, the type `keyword`.
6969

70-
It's interesting because the `reference` property has some special characters. An example of `reference` code is `SBES@DDR4-10000`. As it is a `text`, ES (using the `standard` analyzer) splits the content in tokens ['SBES', 'DDR4', 10000]. So, for example, if you are looking for a product with `DDR4` RAM and, for some reason, the string `DDR4` is present in the reference code of some product X, the product X will be selected, even if it doesn't have `DDR4` in its description. It is an error.
70+
It's interesting because the `reference` property has some special characters. An example of `reference` code is `SBES@DDR4-10000`. As it has the type `text`, ES (using the `standard` analyzer) splits the content in tokens ['SBES', 'DDR4', 10000]. So, for example, if you are looking for a product with `DDR4` RAM and, for some reason, the string `DDR4` is present in the reference code of some product X, the product X will be selected, even if it doesn't have `DDR4` in its description.
7171

72-
So, the script `./reindex.sh` aims to fix it, setting the type `keyword` to `reference` property. The `DDR4` problem won't happen again because, from now on, ES won't tokenize the content present in the `reference` property.
72+
So, the script `./reindex.sh` aims to fix it, setting the type `keyword` to the `reference` property. The `DDR4` search issue won't happen again because, from now on, ES won't tokenize the content present in the `reference` property.
7373

7474
== Running applications using Maven
7575

@@ -219,9 +219,9 @@ It should return something like
219219
[source]
220220
----
221221
{
222-
"name" : "8cbb430221c5",
222+
"name" : "5f932864548a",
223223
"cluster_name" : "docker-cluster",
224-
"cluster_uuid" : "Qf1RvbzXQKimAUR0z_erYA",
224+
"cluster_uuid" : "J8k8aa6eSkOHlgJSZPl8kA",
225225
"version" : {
226226
"number" : "7.17.4",
227227
"build_flavor" : "default",
@@ -263,8 +263,8 @@ It should return something like
263263
[source]
264264
----
265265
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
266-
green open .geoip_databases r_GGDT_iSdm6lr_j1GjfRw 1 0 24 0 25mb 25mb
267-
yellow open ecommerce.products.v1 Z1zkiWaIRAWNaQaa1-RWDQ 1 1 0 0 226b 226b
266+
green open .geoip_databases Ud5Jc_p1SZav1G5CPd6X6g 1 0 40 0 38.3mb 38.3mb
267+
yellow open ecommerce.products.v1 rmL6pbPMQyKroHl9_KXTVQ 1 1 0 0 226b 226b
268268
----
269269

270270
* Check `ecommerce.products.v1` index mapping
@@ -290,10 +290,14 @@ It should return
290290
"format" : "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
291291
},
292292
"description" : {
293-
"type" : "text"
293+
"type" : "text",
294+
"analyzer" : "my_analyzer",
295+
"search_analyzer" : "my_search_analyzer"
294296
},
295297
"name" : {
296-
"type" : "text"
298+
"type" : "text",
299+
"analyzer" : "my_analyzer",
300+
"search_analyzer" : "my_search_analyzer"
297301
},
298302
"price" : {
299303
"type" : "float"
@@ -382,9 +386,9 @@ It should return something like
382386
[source]
383387
----
384388
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
385-
yellow open ecommerce.products.v2 Oms0rQN4RQ-oi-yyqWvJ9Q 1 1 0 0 226b 226b
386-
green open .geoip_databases r_GGDT_iSdm6lr_j1GjfRw 1 0 39 0 37mb 37mb
387-
yellow open ecommerce.products.v1 Z1zkiWaIRAWNaQaa1-RWDQ 1 1 0 0 226b 226b
389+
green open .geoip_databases Ud5Jc_p1SZav1G5CPd6X6g 1 0 40 0 38.3mb 38.3mb
390+
yellow open ecommerce.products.v2 j9zvCjkbQM6ME-h2L5CxJA 1 1 0 0 226b 226b
391+
yellow open ecommerce.products.v1 rmL6pbPMQyKroHl9_KXTVQ 1 1 0 0 226b 226b
388392
----
389393

390394
* Reindex from `ecommerce.products.v1` to `ecommerce.products.v2`
@@ -505,7 +509,7 @@ It should return something like
505509
}
506510
----
507511
+
508-
> As I don't have any products, the `hits` array field is empty
512+
> As we don't have any products, the `hits` array field is empty
509513

510514
== TODO
511515

elasticsearch/mapping-v1.json

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
{
2+
"settings": {
3+
"analysis": {
4+
"analyzer": {
5+
"my_analyzer": {
6+
"tokenizer": "standard",
7+
"filter": [
8+
"lowercase",
9+
"edge_ngram_filter"
10+
]
11+
},
12+
"my_search_analyzer": {
13+
"tokenizer": "standard",
14+
"filter": [
15+
"lowercase"
16+
]
17+
}
18+
},
19+
"filter": {
20+
"edge_ngram_filter": {
21+
"type": "edge_ngram",
22+
"min_gram": 1,
23+
"max_gram": 20
24+
}
25+
}
26+
}
27+
},
228
"mappings": {
329
"properties": {
430
"categories": {
531
"type": "keyword"
632
},
733
"created": {
8-
"type": "date", "format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
34+
"type": "date",
35+
"format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
936
},
1037
"description": {
11-
"type": "text"
38+
"type": "text",
39+
"analyzer": "my_analyzer",
40+
"search_analyzer": "my_search_analyzer"
1241
},
1342
"name": {
14-
"type": "text"
43+
"type": "text",
44+
"analyzer": "my_analyzer",
45+
"search_analyzer": "my_search_analyzer"
1546
},
1647
"price": {
1748
"type": "float"
@@ -25,7 +56,8 @@
2556
"type": "text"
2657
},
2758
"created": {
28-
"type": "date", "format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
59+
"type": "date",
60+
"format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
2961
},
3062
"stars": {
3163
"type": "short"

elasticsearch/mapping-v2.json

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
{
2+
"settings": {
3+
"analysis": {
4+
"analyzer": {
5+
"my_analyzer": {
6+
"tokenizer": "standard",
7+
"filter": [
8+
"lowercase",
9+
"edge_ngram_filter"
10+
]
11+
},
12+
"my_search_analyzer": {
13+
"tokenizer": "standard",
14+
"filter": [
15+
"lowercase"
16+
]
17+
}
18+
},
19+
"filter": {
20+
"edge_ngram_filter": {
21+
"type": "edge_ngram",
22+
"min_gram": 1,
23+
"max_gram": 20
24+
}
25+
}
26+
}
27+
},
228
"mappings": {
329
"properties": {
430
"categories": {
531
"type": "keyword"
632
},
733
"created": {
8-
"type": "date", "format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
34+
"type": "date",
35+
"format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
936
},
1037
"description": {
11-
"type": "text"
38+
"type": "text",
39+
"analyzer": "my_analyzer",
40+
"search_analyzer": "my_search_analyzer"
1241
},
1342
"name": {
14-
"type": "text"
43+
"type": "text",
44+
"analyzer": "my_analyzer",
45+
"search_analyzer": "my_search_analyzer"
1546
},
1647
"price": {
1748
"type": "float"
@@ -25,7 +56,8 @@
2556
"type": "text"
2657
},
2758
"created": {
28-
"type": "date", "format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
59+
"type": "date",
60+
"format": "strict_date_time_no_millis||yyyy-MM-dd'T'HH:mmZZ"
2961
},
3062
"stars": {
3163
"type": "short"

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.2</version>
8+
<version>2.7.3</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111

product-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<properties>
1717
<org.mapstruct.version>1.5.2.Final</org.mapstruct.version>
1818
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
19-
<springdoc-openapi.version>1.6.9</springdoc-openapi.version>
19+
<springdoc-openapi.version>1.6.11</springdoc-openapi.version>
2020
</properties>
2121

2222
<dependencies>

0 commit comments

Comments
 (0)