front / wp-redisearch

Flexible and fast search engine for Wordpress.
27 stars 5 forks source link

Custom query #11

Open pratik9722 opened 3 years ago

pratik9722 commented 3 years ago

Please provide documentation for custom query Can we use this plugin along with your plugin https://github.com/devgeniem/redipress

Recommendations Only read should happen from redis. Write, update & delete should be perform at the same time on MySQL as well as redis so redis also has fresh data at each time still take the benifits of reads from the redis.

foadyousefi commented 3 years ago

Thanks for the suggestion. There will be some changes to the organizational structure of the plugin very soon and in-depth documentation will be provided.

As for using it along with RediPress, I'm afraid it is not. Our plugin supports the latest versions of Redis and RediSearch since RediSearch 2.0 is completly re-written.

As for the recommendations, yes, only read happens in the Redis, create, update and delete posts, happens directly on MySQL and Redis automatically updates indexed data.

gigabyteservice commented 3 years ago

1) what about the API endpoints e.g /wp-json/wp/v2/media all the data which we can see at the API endpoints also come from wp-redisearch? (meaning from Redis not MySQL correct?) if yes then what about custom API end Points

2) If you can give us an idea about how we can create a custom post type or custom query that gives the benefits of Redis then it's very good.

foadyousefi commented 3 years ago

So sorry for so late answer. Currently, the way this plugin setup is replacing query in the posts_request filter if it's search and main query. But if really necessary and you think can be useful, it can be added to all queries or at least the option to use it for WP_Query.

I think point 2 is out of this plugins scope dough.

foadyousefi commented 3 years ago

Added a filter in which forces RediSearch to replace Wordpress post query.

apply_filters( 'wp_redisearch_force_redisearch', FALSE, $query ) ) You can return TRUE when your criterias are correct, so the plugin tries to fetch posts from RediSearch index instead of Database.