admin管理员组文章数量:1336633
I am a noob so appreciate your patience :-)
I am trying to use ElasticSearch with a Wordpress installation using the ElasticPress plugin. All configured and in production. Amazing results so far.
I am confused about where all ES is being used.
"By default it only works on the search page. If you want to use it to process any other page, or index, loops,home page, archives, tax (WP_Query) you must add to the query: 'ep_integrate' => true "
Can someone please help me with implementing this using a code snippet?
Thanks!
I am a noob so appreciate your patience :-)
I am trying to use ElasticSearch with a Wordpress installation using the ElasticPress plugin. All configured and in production. Amazing results so far.
I am confused about where all ES is being used.
"By default it only works on the search page. If you want to use it to process any other page, or index, loops,home page, archives, tax (WP_Query) you must add to the query: 'ep_integrate' => true "
Can someone please help me with implementing this using a code snippet?
Thanks!
Share Improve this question asked May 26, 2020 at 17:04 PeterPeter 112 bronze badges 4- As the docs say, out of the box, it's only used to replace the default search engine. Where else are you wanting to use it? – WebElaine Commented May 26, 2020 at 17:13
- I just installed it on a site myself, specifically to improve the default search, and WOW! It's really good. – Tony Djukic Commented May 26, 2020 at 21:57
- @TonyDjukic: Yes, it has remarkable performance and saved server resources for me. – Peter Commented May 26, 2020 at 22:33
- Ok, I'm about to test this... ...going to install Query Monitor first.... I'll post an answer with what I find. – Tony Djukic Commented May 27, 2020 at 1:18
1 Answer
Reset to default 1So here's how I recently applied it and what my observations were:
An FAQ page was loading at anywhere between 0.6s to 0.9s. It's a page intended to display all FAQs but broken up into their FAQ categories. (It's an entirely custom post_type and custom taxonomy.) My team are still adding FAQs from the clients existing site as well as new documents they've provided. So it's still pretty light weight.
I'm running a get_terms()
to grab all the FAQ taxonomy IDs, then a foreach to loop through them and pull every FAQ post within each FAQ Category. (There are duplicates, but that's by design as per client request.)
I'm thinking this is eventually going to be a pretty big page, lots of categories from my get_terms()
so lots of unique new WP_Query
within the foreach.
According to Query Monitor the page is already executing 17 core WP queries (aka WP_Query
), but in 0.6 to 0.9s, so it's ok, for now.
Now we test with ElasticPress:
I added a single line to my query_args
.
$query_args = array(
'ep_integrate' => true, //this single line...
'post_type' => 'prefix_faqs',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'prefix_faq_cat',
'field' => 'term_id',
'terms' => $faq_term->term_id,
)
),
'orderby' => 'menu_order',
'order' => 'ASC'
);
$faq_query = new WP_Query( $query_args );
Page loads are now completed in 1.15s to 1.22s. So a bit slower. This is because I'm communicating with another server, so there's that nominal delay and expected I guess.
But here's the interesting bit... ...the query count went down from 17 to 5. The WP Queries in my foreach()
loop aren't taxing the server - they're executing via ElasticPress.
As of right now, it appears slower, but less taxing on the server. And when I say 'appears slower' I don't mean visually. Just observing with your eyes the difference is imperceptible - everything is loaded and in place and by the time you get to an FAQ category section the page is fully loaded.
However, once this page has the volume of FAQs I'm anticipating, I imagine applying ElasticPress will have both the benefit of reducing server load AND reducing load times.
Hope that helps.
本文标签: searchUsing ElasticSearch on Wordpress
版权声明:本文标题:search - Using ElasticSearch on Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742399244a2467547.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论