I tried with rawsql in django, but I can't find a way to get queries debug info :s but there is a good ration match in 25 queries
def del_char(text, num_chars_to_remove):
for i in range(num_chars_to_remove):
remove = randint(0, len(text))
text = text[:remove] + text[remove + 1 :]
return text
def test_query(num_chars_to_remove):
seeds = models.Test.objects.all().order_by("?")[:5]
print("Remove %s characters:" % num_chars_to_remove)
for seed in seeds:
with connection.cursor() as cursor:
query = """
SELECT lookup_field, lookup_field <-> %s AS dist
FROM music_test
ORDER BY dist LIMIT 10;
"""
lookup = del_char(seed.lookup_field, num_chars_to_remove)
cursor.execute(query, [lookup])
r = list(cursor.fetchall())
if r[0][0] != seed.lookup_field:
print("Wrong match" + r[0][0])
def test_with_del():
for i in range(5):
test_query(i + 1)
Remove 1 characters:
Remove 2 characters:
Remove 3 characters:
Remove 4 characters:
Wrong matchu2 i wll follow
Remove 5 characters: