Johnny Woo
Johnny Woo

Reputation: 187

Sphinx: what exactly does indexer --merge do?

Sphinx manual says that index merging should keep old keywords along with new ones:

Note, however, that the "old" keywords will not be automatically removed in such cases. For example, if there's a keyword "old" associated with document 123 in DSTINDEX, and a keyword "new" associated with it in SRCINDEX, document 123 will be found by both keywords after the merge.

I cannot reproduce this.

  1. We have a document with id 1 and text 'one' in index main
  2. Text in the DB table changes from 'one' to 'two'
  3. indexer --rotate delta
  4. indexer --rotate --merge main delta
  5. Wait for searchd to reload the index
  6. Now we can find document 1 by SELECT id FROM main WHERE match('two'), but match('one') does not find anything.

Sources for both indexes are defined essentially as:

sql_query = SELECT id, text FROM tbl

I have also tried to specify keywords via sql_joined_field and merge does not keep old keywords from it too.

Does this mean the manual is wrong? Is it safe to assume that if SRCINDEX has info for an ID (attributes and text keywords), merge process will discard everything DSTINDEX had for that ID and replace it with new info?

Upvotes: 1

Views: 1986

Answers (2)

Iaroslav Vorozhko
Iaroslav Vorozhko

Reputation: 1719

I asked Andrey Aksenoff (creator of Sphinx) about this. He said that now they clean duplicate id while merging if index docinfo is extern.

So yes, it is a bug in documentation.

Upvotes: 2

Iaroslav Vorozhko
Iaroslav Vorozhko

Reputation: 1719

If Sphinx found duplicate IDs when they are eliminated from search results, so you Sphinx return only unique IDs. What's why you didn't see them in search results.

Upvotes: 0

Related Questions