parisholley / wordpress-fantastic-elasticsearch

Improve wordpress search performance/accuracy and enable faceted search by leveraging an ElasticSearch server.
MIT License
162 stars 64 forks source link

Re-index Data failing when some post have the same post_dates #143

Open nigelheap opened 7 years ago

nigelheap commented 7 years ago

This is actually kind of an issue in mysql but... when you have post_date fields that are the same. LIMIT and OFFSET has a pretty hard time working correctly.

The problem follows though into wordpress and the get_post() function.

The reason I have posts with the same date is because they are being bulk imported and some of them are imported in the same second.

Here is an example of the ids sent to the indexer in the first 2 loops

First block of 10 [0] => 6768 [1] => 6769 [2] => 6766 [3] => 6767 [4] => 6765 [5] => 6719 [6] => 6718 [7] => 6724 [8] => 6720 [9] => 6723

Second block of 10 [0] => 6732 [1] => 6729 [2] => 6718 [3] => 6719 [4] => 6724 [5] => 6734 [6] => 6730 [7] => 6733 [8] => 6725 [9] => 6726

You can see that 6719, 6718 and 6724 are in both the loops. This means that the post count ends up being incorrect and the indexer never indexes everything.

I know that in your plugin that you can overwrite the arguments being send to the indexer with elasticsearch_indexer_get_posts but I might be better to order them by ID or maybe give the option in the interface because this might stump some people.