You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I was testing the description field with broader texts and terms to achieve good search results, a small issue came to me. I can't affirm if this is a bug or expected behaviour, but I would like to expose this line of thought.
The potential bug is:
Either as sanitizer of the description field or by invocation of the method (e.g., product mutation), when the clean_editor_js method is required, blocks (EditorJS JSON definitions) might be being wrongly concatenated.
As a result, the search vector will be populated with terms that might not make sense.
Steps to reproduce the problem
Let's grab the default demo database and the product "Apple Juice" (in my case id 72)
[
{
"id": 72,
"name": "Apple Juice",
"description": "{\"time\": 1625709710445, \"blocks\": [{\"data\": {\"text\": \"Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.\"}, \"type\": \"paragraph\"}], \"version\": \"2.20.0\"}",
"updated_at": "2021-07-08 02:04:19.359545",
"product_type_id": 9,
"category_id": 14,
"seo_description": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",
"seo_title": "",
"charge_taxes": true,
"weight": 1000,
"metadata": "{\"vatlayer.code\": \"standard\", \"vatlayer.description\": \"standard\"}",
"private_metadata": "{}",
"slug": "apple-juice",
"default_variant_id": 202,
"description_plaintext": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",
"search_vector": "'appl':1A,22B 'autumn':18B 'bottl':16B 'brought':23B 'english':21B 'fell':3B 'graviti':27B 'head':12B 'juic':2A 'newton':10B 'straight':4B 'tast':19B 'tree':7B",
"rating": null
}
]
The result of description_plaintext and the search_vector fields are:
Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.
'appl':1A,22B
'autumn':18B
'bottl':16B
'brought':23B
'english':21B
'fell':3B
'graviti':27B
'head':12B
'juic':2A
'newton':10B
'straight':4B
'tast':19B
'tree':7B"
Let's insert some additional texts on the description field
{
"id": 72,
"name": "Apple Juice",
"description": "{\"time\": 1625710749431, \"blocks\": [{\"data\": {\"text\": \"Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.\"}, \"type\": \"paragraph\"}, {\"data\": {\"text\": \"Apple juice is 88% water and 11% carbohydrates (including 9% sugars), with negligible content of protein or fat.\"}, \"type\": \"paragraph\"}, {\"data\": {\"items\": [\"organic fabrication\", \"toxin-free \", \"healthy lifestyle\", \"made with love\"], \"style\": \"ordered\"}, \"type\": \"list\"}], \"version\": \"2.20.0\"}",
"updated_at": "2021-07-08 02:19:13.819220",
"product_type_id": 9,
"category_id": 14,
"seo_description": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",
"seo_title": "",
"charge_taxes": true,
"weight": 1000,
"metadata": "{\"vatlayer.code\": \"standard\", \"vatlayer.description\": \"standard\"}",
"private_metadata": "{}",
"slug": "apple-juice",
"default_variant_id": 202,
"description_plaintext": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.Apple juice is 88% water and 11% carbohydrates (including 9% sugars), with negligible content of protein or fat.organic fabricationtoxin-free healthy lifestylemade with love",
"search_vector": "'11':33B '88':30B '9':36B 'appl':1A,22B 'autumn':18B 'bottl':16B 'brought':23B 'carbohydr':34B 'content':40B 'english':21B 'fabricationtoxin':46B 'fabricationtoxin-fre':45B 'fat.organic':44B 'fell':3B 'free':47B 'gravity.apple':27B 'head':12B 'healthi':48B 'includ':35B 'juic':2A,28B 'lifestylemad':49B 'love':51B 'neglig':39B 'newton':10B 'protein':42B 'straight':4B 'sugar':37B 'tast':19B 'tree':7B 'water':31B",
"rating": null
}
The result of description_plaintext and the search_vector fields are:
Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.Apple❗ juice is 88% water and 11% carbohydrates (including 9% sugars), with negligible content of protein or fat.organic❗ fabricationtoxin-free❗ healthy lifestylemade❗ with love
'11':33B
'88':30B
'9':36B
'appl':1A,22B
'autumn':18B
'bottl':16B
'brought':23B
'carbohydr':34B
'content':40B
'english':21B
'fabricationtoxin':46B ❗
'fabricationtoxin-fre':45B ❗
'fat.organic':44B ❗
'fell':3B
'free':47B
'gravity.apple':27B ❗
'head':12B
'healthi':48B
'includ':35B
'juic':2A,28B
'lifestylemad':49B ❗
'love':51B
'neglig':39B
'newton':10B
'protein':42B
'straight':4B
'sugar':37B
'tast':19B
'tree':7B
'water':31B"
What I expected to happen
I think the method clean_editor_js can separate each block with space.
System information
Saleor version:
dev (current master)
3.0
2.11
2.10
Operating system:
Windows
Linux
MacOS
Docker
Other
The text was updated successfully, but these errors were encountered:
What I'm trying to achieve
When I was testing the description field with broader texts and terms to achieve good search results, a small issue came to me. I can't affirm if this is a bug or expected behaviour, but I would like to expose this line of thought.
The potential bug is:
Either as sanitizer of the description field or by invocation of the method (e.g., product mutation), when the clean_editor_js method is required, blocks (EditorJS JSON definitions) might be being wrongly concatenated.
As a result, the search vector will be populated with terms that might not make sense.
Steps to reproduce the problem
The result of description_plaintext and the search_vector fields are:
Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.
The result of description_plaintext and the search_vector fields are:
Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.Apple❗ juice is 88% water and 11% carbohydrates (including 9% sugars), with negligible content of protein or fat.organic❗ fabricationtoxin-free❗ healthy lifestylemade❗ with love
What I expected to happen
I think the method clean_editor_js can separate each block with space.
System information
Saleor version:
Operating system:
The text was updated successfully, but these errors were encountered: