Marcin
Marcin

Reputation: 96

How can I update records in sphinx search index by sql query?

I have a problem when I want update record in sphinx search index

mysql> UPDATE indexname SET field = 'value' where id = 295;

ERROR 1064 (42000): sphinxql: syntax error, unexpected QUOTED_STRING, expecting CONST_INT (or 3 other tokens) near ''value' where id = 295'

Is it possible to update some text field in disk index (not RT)

My sphinx version is: 2.1.7-id64-release (rel21-r4638)

Thanks for some ideas:)

Upvotes: 1

Views: 2510

Answers (1)

barryhunter
barryhunter

Reputation: 21091

No. You can not update a Field in a RT index.

To 'update' a Field, you need to delete the whole row, and re-insert it fresh. There is a REPLACE INTO command to do both in one step.


Only attributes can be updated. (Early versions of sphinx can't update string attributes, ie only update numeric attributes, but I think the very latest version has gained the ablity to update even string attributes. )


Edit, actully notice now you mention disk-indexes, not RT indexes. Still can't update Fields (ie neither on RT or disk-indexes)

Again you can update some attributes, with some restrictions, see http://sphinxsearch.com/docs/current.html#api-func-updateatttributes (not sure the latest support for updating string attributes on RT indexes, is even extended to disk-indexes)

... in short UPDATE works pretty much the same on both disk and RT indexes. RT indexes just have INSERT/REPLACE/DELETE which you can't use at all with disk indexes.

Upvotes: 5

Related Questions