wp-redisearch icon indicating copy to clipboard operation
wp-redisearch copied to clipboard

Custom query

Open pratik9722 opened this issue 4 years ago • 4 comments

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.

pratik9722 avatar Jan 27 '21 23:01 pratik9722

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.

foadyousefi avatar Jan 28 '21 11:01 foadyousefi

  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.

gigabyteservice avatar Feb 03 '21 16:02 gigabyteservice

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 avatar May 03 '21 16:05 foadyousefi

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.

foadyousefi avatar May 03 '21 18:05 foadyousefi