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

Convert search criteria into a filter #126

Open peussen opened 9 years ago

peussen commented 9 years ago

I ran into a problem with my site, which after a couple of hours searching i tracked down to how this plugin worked in combination with another plugin. It appears the other plugin (which i will ask for a fix as well), does some queries in the pre_get_posts, which screws up this plugin.

Basically what happens is that a plugin does some queries in the pre_get_posts to determine if it should do something. These queries do appear to be the main_query, even though they are not. I guess you ran into somewhat similair problems (looking at the attempted variable).

So to allow other people with similair problems to correct this i introduced this filter. Basically you will get one filter per search type. So you should get:

People can then add their own criteria (or remove the default ones) when needed.

If you have some alternative solution i could not think of, which will not require this pull request, please let me know!

peussen commented 9 years ago

I'm looking into one test scenario right now which seem to act up. If that one is due to this change, i will cancel this request. P

peussen commented 9 years ago

Looks like the test failure on my side was caused by something else. All tests work for me now.