PostgreSQL full-text search retrival from id gap
Found my stupid mistake...
instead of running the query as my_table.objects.raw(sql_query) I was creating a connection to another db with

conn = psycopg2.connect("dbname='wrong_db' user='my_user' password='my_password'")
cur = conn.cursor() 
cur.execute(sql_query)


so lesson learnt... use the Django built-in capabilities to eliminate the possibility of a connection to a wrong db.

The coincidence that I was getting ids from my gap range was caused by the fact that at some point I had tried to import (unsuccessfully) the entries from wrong_db to my db and this created the gap in ids.