Hi everyone - I am sorry if this is not the right place or format to ask
for this typo of help.
I have been trying to solve this issue for a while but have not had any
luck.
I created a Custom Lookup to be able to do full text search on mysql:
```
# lookup
class Search(models.Lookup):
lookup_name = "search"
def as_mysql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = lhs_params + rhs_params
return f"MATCH (%s) AGAINST (%s IN BOOLEAN MODE)" % (lhs, rhs), params
models.TextField.register_lookup(Search)
# Migrations
from django.db import migrations, models
# Table details
table_name = "by_api_casesnapshot"
field_name = "text"
index_name = f"{table_name}_{field_name}_index"
class Migration(migrations.Migration):
dependencies = [("by_api", "0033_add_tag_color")]
operations = [
migrations.CreateModel(...), # As auto-generated
migrations.RunSQL(
f"CREATE FULLTEXT INDEX {index_name} ON {table_name}
({field_name})",
f"DROP INDEX {index_name} ON {table_name}",
),
]
```
The __search works fine, but I use it inside a test suite it returns empty.
Any help or feedback is appreciated
Details are here
https://stackoverflow.com/questions/61486725/django-mysql-fulltext-search-works-but-not-on-tests
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/3fea10db-692b-4865-9733-b87bb647055f%40googlegroups.com.