Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Transforming WordPress Search and Query Performance with Elasticsearch

1,932 views

Published on

Learn how to improve search relevancy and query speed in WordPress with Elasticsearch and ElasticPress

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Transforming WordPress Search and Query Performance with Elasticsearch

  1. 1. Modernizing WordPress Search with Elasticsearch
  2. 2. Who Am I? • My name is Taylor Lovett • Director of Web Engineering at 10up • Open source community member • WordPress core contributor • ElasticPress team member @tlovett12
  3. 3. Doesn’t WordPress have search built-in?
  4. 4. WordPress Search is Rudimentary • Only searches post title, content, and excerpt. • Relies on MySQL and thus is slow. • Relevancy calculations are poor and overly simplistic. • Not able to handle any advanced filtering.
  5. 5. Think Beyond Search
  6. 6. WordPress Complex Queries Are Slow • Querying for posts that contain multiple meta keys. • Querying for posts that contain multiple taxonomies.
  7. 7. What is Elasticsearch? http://www.elastic.co
  8. 8. Elasticsearch • Open-source search server written in Java based on a technology called Lucene (open- source search software by Apache). • A standalone database server that provides a RESTful interface to accept and store data in a way that is optimized for search and multi- dimensional queries. • Extremely scalable, performant, and reliable
  9. 9. Elasticsearch • Relevant results • Performant aggregation queries • Autosuggest • Fuzzy matching • Geographic searches and queries • Filterable searches and queries • Data weighting • Much more
  10. 10. Get an Elasticsearch Server • Very flexible and customizable. There is not really a “one size fits all” setup. Generally, you have two options: • Option 1: Pay someone else to manage/host your Elasticsearch cluster (SaaS) • Option 2: Host your own cluster
  11. 11. Elasticsearch SaaS • elasticpress.io • qbox.io • heroku.com • elastic.co
  12. 12. What is ElasticPress? https://wordpress.org/plugins/elasticpress
  13. 13. ElasticPress ElasticPress is a fast and flexible search and query engine for WordPress.
  14. 14. ElasticPress Features • Instantly find the content you’re looking for. The first time. Advanced relevancy algorithm which includes date weighting, term/meta searching, fuzzy matching, and more. • Search and query across multiple blogs in a multisite instance. • Extremely performant related content widget.
  15. 15. ElasticPress Features • Dramatically improve performance of admin queries to assist editors in finding content. • Indexes text inside of popular file types (pdf, ppt, doc, etc), and adds those files types to search results. • Autosuggest for search - suggest relevant content as text is entered into the search field. • WooCommerce integration that improves faceting and product look up speed as well as order search in the admin.
  16. 16. ElasticPress Requirements • WordPress 3.7+ • An instance of Elasticsearch.
  17. 17. Installation • Github: http://github.com/10up/elasticpress • WordPress.org: http://wordpress.org/plugins/ elasticpress
  18. 18. Connect to Elasticsearch
  19. 19. Activate Features
  20. 20. Sync Your Content
  21. 21. Query API
  22. 22. Query Integration new WP_Query( array(
 ’s’ => ‘search terms’,
 ‘author_name’ => ‘taylor’,
 …
 ) ); new WP_Query( array(
 ’ep_integrate’ => ‘true’,
 ‘author_name’ => ‘taylor’,
 …
 ) ); new WP_Query( array(
 ‘author_name’ => ‘taylor’,
 …
 ) );
  23. 23. Advanced Query API • Search taxonomy terms • Filter by taxonomy terms (unlimited dimensions) • Search post meta • Filter by post meta (unlimited dimensions) • Search authors • Filter by authors • Search across blogs in multisite • Complex date filtering • more!
  24. 24. Example Queries new WP_Query( array(
 ’s’ => ‘vienna austria’,
 ‘sites’ => ‘all’,
 ) );
  25. 25. Example Queries new WP_Query( array(
 ’s’ => ‘vienna austria’,
 ‘search_fields’ => array(
 ‘post_title’,
 ‘post_content’,
 ‘taxonomies’ => array( ‘category’ ),
 ),
 ) );
  26. 26. Example Queries new WP_Query( array(
 ’s’ => ‘vienna austria’,
 ‘post_type’ => ‘page’,
 ‘author_name’ => ‘taylor’,
 ‘search_fields’ => array(
 ‘post_title’,
 ‘post_content’,
 ‘meta’ => array( ‘city_name’ ),
 ),
 ) );
  27. 27. Example Queries new WP_Query( array(
 ’s’ => ‘vienna austria’,
 ‘tax_query’ => array(
 array(
 ‘taxonomy’ => ‘category’,
 ‘terms’ => array( ‘term1’, ‘term2’ ),
 ),
 ),
 ‘search_fields’ => array(
 ‘post_title’,
 ‘post_content’,
 ‘meta’ => array( ‘city_name’ ),
 ‘author_name’,
 ),
 ‘site’ => 3,
 ) );
  28. 28. Example Queries new WP_Query( array(
 ‘ep_integrate’ => true,
 ‘tax_query’ => array(
 array(
 ‘taxonomy’ => ‘category’,
 ‘terms’ => array( ‘term1’, ‘term2’ ),
 ‘operator’ => ‘or’,
 ),
 array(
 ‘taxonomy’ => ‘custom_tax’,
 ‘terms’ => array( ‘customterm1’ ),
 ),
 array(
 ‘taxonomy’ => ‘post_tag’,
 ‘terms’ => array( ‘tag1’ ),
 ),
 ‘relation’ => ‘OR’,
 ),
 ) );
  29. 29. Example Queries new WP_Query( array(
 ‘ep_integrate’ => true,
 ‘meta_query’ => array(
 array(
 ‘key’ => ‘city_name’,
 ‘value’ => ‘vienna’,
 ),
 array(
 ‘key’ => ‘number_key’,
 ‘value’ => 5,
 ‘compare’ => ‘>’,
 ),
 array(
 ‘key’ => ‘exists_key’,
 ‘compare’ => ‘exists’,
 ),
 ),
 ) );
  30. 30. WP_Query Integration • We want to be able to run all (slower) WP_Query instances through Elasticsearch. • This means we have to support every query parameter which isn’t the case yet. Github contains a full list of parameters WP_Query supports with ElasticPress and usage for each parameter.
  31. 31. ElasticPress in Your Language • ElasticPress is designed to be internationalized. • Out of the box, it will work fine with most languages.
  32. 32. Analysis and Analyzers • When a document is indexed in Elasticsearch, text is analyzed, broken into terms (tokenized), and normalized with token filters. • In normalization, strings might be lowercased and plurals stripped.
  33. 33. Custom Analyzers • ElasticPress by default uses a pretty standard set of analyzers intended for the English language. • We can easily customize our analyzers for use with other languages by filtering ep_config_mapping (see EP source code). • You can read about language specific analyzers here:
 
 http://www.elasticsearch.org/guide/en/elasticsearch/ reference/current/analysis-lang-analyzer.html
  34. 34. Documentation Full documentation with installation instructions:
 
 https://github.com/10up/ElasticPress
  35. 35. Feedback and Continuing Development • If you are using ElasticPress on a project, please let us know and give us feedback. • Pull requests are welcome!
  36. 36. Questions? We need to send a PUT request to this endpoint with our post data. Of course we must authenticate before doing this. @tlovett12 taylor.lovett@10up.com http://elasticpress.io

×