mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-02-17 19:01:10 +01:00
improve validation on text indexing, for search (#294)
This commit is contained in:
parent
28031f07e5
commit
f974d78270
@ -395,11 +395,11 @@ class Media(models.Model):
|
|||||||
b_tags = " ".join([tag.title.replace("-", " ") for tag in self.tags.all()])
|
b_tags = " ".join([tag.title.replace("-", " ") for tag in self.tags.all()])
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
helpers.clean_query(self.title),
|
self.title,
|
||||||
self.user.username,
|
self.user.username,
|
||||||
self.user.email,
|
self.user.email,
|
||||||
self.user.name,
|
self.user.name,
|
||||||
helpers.clean_query(self.description),
|
self.description,
|
||||||
a_tags,
|
a_tags,
|
||||||
b_tags,
|
b_tags,
|
||||||
]
|
]
|
||||||
@ -407,6 +407,8 @@ class Media(models.Model):
|
|||||||
text = " ".join(items)
|
text = " ".join(items)
|
||||||
text = " ".join([token for token in text.lower().split(" ") if token not in STOP_WORDS])
|
text = " ".join([token for token in text.lower().split(" ") if token not in STOP_WORDS])
|
||||||
|
|
||||||
|
text = helpers.clean_query(text)
|
||||||
|
|
||||||
sql_code = """
|
sql_code = """
|
||||||
UPDATE {db_table} SET search = to_tsvector(
|
UPDATE {db_table} SET search = to_tsvector(
|
||||||
'{config}', '{text}'
|
'{config}', '{text}'
|
||||||
|
Loading…
Reference in New Issue
Block a user