Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search index fails to populate #66

Open
chrisspen opened this issue Nov 23, 2015 · 1 comment
Open

Search index fails to populate #66

chrisspen opened this issue Nov 23, 2015 · 1 comment

Comments

@chrisspen
Copy link

I installed 0.9.3 following the instructions in the README in an app using Django 1.5 with a PostgreSQL 9.3 backend.

However, when I ran ./manage update_search_field myapp mymodel it runs without error but nothing gets populated into the new search_index column on mymodel.

One possible problem may be that mymodel exists on a non-default database, and the command update_search_field doesn't support a --database attribute like many commands do. However, even when I patch the command to use the correct database connection, still nothing populates.

This is the SQL being run by the command:

UPDATE "myapp_mymodel" SET "search_index" = setweight(to_tsvector('pg_catalog.english', coalesce("myapp_mymodel"."account_number", '')), 'D');

If I run:

SELECT account_number FROM myapp_mymodel;

I see a non-blank value for every record, but when I run:

SELECT search_index FROM myapp_mymodel;

it returns nothing but blank values.

If I manually run that UPDATE statement, it populates correctly, so I'm assuming I didn't properly patch the code to use the correct connection.

What am I doing wrong?

@chrisspen
Copy link
Author

I think I figured out how to properly patch the code. Changing the using isn't necessary. All I had to do to get this working was to change line 163 of models.py from:

sql = "UPDATE %s SET %s = %s %s;" % (

to:

sql = "UPDATE %s SET %s = %s %s; COMMIT;" % (

I see that line was already under an atomic() context manager, so I'm not sure why this was required. Is this a bug or is it possibly something strange in my configuration? Should I submit a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant