Skip to content

Commit

Permalink
Merge pull request #697 from basedosdados/dev
Browse files Browse the repository at this point in the history
Update staging
  • Loading branch information
jhonylucas74 authored Oct 30, 2024
2 parents 4e95ab4 + 8dad202 commit aff1214
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 8 additions & 2 deletions backend/apps/api/v1/search_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def __init__(self, *args, **kwargs):
"tokenizer": "edgengram",
"filter": ["asciifolding", "lowercase"],
},
"snowball_pt": {
"type": "snowball",
"language": "Portuguese",
"filter": ["asciifolding"],
},
"snowball_en": {
"type": "snowball",
"language": "English",
"filter": ["asciifolding"],
},
"snowball_pt": {
"snowball_es": {
"type": "snowball",
"language": "Portuguese",
"language": "Spanish",
"filter": ["asciifolding"],
},
}
Expand Down Expand Up @@ -63,6 +68,7 @@ def build_schema(self, fields):
"edgengram": {"type": "text", "analyzer": "edgengram"},
"snowball_pt": {"type": "text", "analyzer": "snowball_pt"},
"snowball_en": {"type": "text", "analyzer": "snowball_en"},
"snowball_es": {"type": "text", "analyzer": "snowball_es"},
}
mapping.update({field_class.index_fieldname: field_mapping})
return (content_field_name, mapping)
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/api/v1/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DatasetIndex(indexes.SearchIndex, indexes.Indexable):
)
table_description_es = indexes.MultiValueField(
model_attr="tables__description_es",
default="",
null=True,
indexed=False,
)

Expand Down
5 changes: 2 additions & 3 deletions backend/apps/api/v1/search_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def search(self):
self.searchqueryset
.auto_query(q)
.filter_and(**{"text.edgengram": q})
.filter_or(**{"text.snowball_pt": q})
.filter_or(**{"text.snowball_en": q})
) # fmt: skip
.filter_or(**{f"text.snowball_{self.locale}": q})
)
else:
sqs = self.no_query_found()

Expand Down

0 comments on commit aff1214

Please sign in to comment.