Mustafa Uysal

I'm traveling light, it's au revoir…

Elasticsearch and Nefisyemektarifleri.com

wordpress-search

I want to explain how we implemented elasticsearch on NefisYemekTarifleri.com

About NefisYemekTarifleri: nefisyemektarifleri.com is largest recipe site of Turkey. We have more than 120k recipes that reaching millions of users.

The Problem

1) Everybody hate expensive %like% queries. In fact, we hate queries hitting mysql directly. So need to prevent them.

2) We want to provide better search experience. For example, when users want cook italian pizza that include cheese and olives without pepper and  cook within 45 minutes.”, we need to find result.

ElasticPress

We are using ElasticPress behind our custom wrapper plugin. It is great plugin that directly integrates with the WP_Query object returning results from Elasticsearch. Our wrapper plugins solve some specific problems by using ElasticPress’s filters and actions.

Taxonomies

Taxonomies help us to understand recipe’s properties and using them to filtering results. We have more than 10 custom taxonomies that helps to find answers. Which cuisine? Which cooking techniques? What kind of occasions? cooking time? etc…

Too hard to manage taxonomies!

Our editorial team publishing hundreds of post every day and previous posts haven’t taxonomies. So here is the question, how to handle taxonomies without pain?

– Answer is, ask to people. We are community driven network.

And, we wrote new plugin “taxonomy feeder” 🙂

Taxonomy feeder, asking question about recipes and collecting answers to filling missing taxonomies. For example, people says that recipe is salty, that’s salty.

Asking simple yes/no question to understanding difficulty level.

taxonomy-feeder
Screen capture with google translated. You can see live as well.

Autocompletion

suggesting

Autocompletion like twitter, finding search terms and users.

We’ve used Elasticsearch’s completion suggester but want to suggest popular terms. So we get results from google analytics and unfortunately, we are still using mysql for users.

Trending Searches

trending-search

Look at bottom of image, hot searches listed. Keeping searches with another index, and serving hottest results within latest 5 minutes.

Language Problems

Turkish alphabet has non-english letters,  (İ,Ö,Ç,ç,ğ,Ğ,ü,Ü,Ş,ş)  and this is another problem to solve.

For example, I’m using English keyboard and if I wrote “kasarli pogaca” instead of “kaşarlı poğaça” I can’t get any result without fuzziness.

I find answer on Greg’s blog and the problem fixed by using ICU analysis plugin.

Our analyzer:

[code language=”php”]
$analyzer = array(‘type’ => ‘custom’,
‘tokenizer’ => ‘icu_tokenizer’,
‘filter’ => array( ‘standard’, ‘lowercase’,’icu_normalizer’,’icu_folding’ ),
‘language’ => ‘Turkish’,
)
[/code]

nefisyemektarifleri-elasicsearch

Summary and Future Plans

Our brand new search engine is not available for publicly, it will be available when taxonomies done.

Implementation of search system is not easy, key point is understanding to “search terms meaning” for user. Elasticsearch is dramatically fast search engine and ElasticPress is the bridge between Elasticsearch and WordPress. (Thanks 10up)

We want to use elasticsearch for all WP_Queries. – (trying https://github.com/alleyinteractive/es-wp-query)

Cheers,

One response

  1. […] millions of users. We switched our search infrastructure to Elasticsearch at the end of 2015. (I wrote about it.) Our cluster running smoothly for […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.