Your SlideShare is downloading. ×
Enhance WordPress Search Using Sphinx
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Enhance WordPress Search Using Sphinx

1,237
views

Published on

This presentation provide the details of what is the problem with WordPress Search and how Full-Text search on WordPress can be used using Sphinx

This presentation provide the details of what is the problem with WordPress Search and how Full-Text search on WordPress can be used using Sphinx

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,237
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Move slide of the relevant search result to lastSpecify we server requirement to install Sphinx first Add more screens if possibleSpecify the the domain of each solide properlyMake it around 15 to 20 mins if possible
  • /usr/local/sphinx/bin/searchd --config /Applications/MAMP/htdocs/wpsphinx/wp-content/uploads/sphinx/sphinx.conf --stop to stop it manually
  • Transcript

    • 1. Enhance WordPress Search using Sphinx
    • 2. I’m Roshan Bhattarai • • • • • CTO @ Proshore Co-author – PHP AJAX COOKBOOK A Developer and learner Sometime I blog @ http://roshanbh.com.np Twitter/Facebook/Linkedin @roshanbh
    • 3. What’s the problem with search in WordPress
    • 4. Problem with default WordPress Search • Default WordPress uses SQL like operator and % wildcard character to get search result • SQL’s Like operator doesn’t care much about the relevancy of the result • Like operation is too slow in large set of textual data • WordPress sort the search result by date
    • 5. Ok let’s improve the WordPress Search
    • 6. So what’s resolution ? • Use the MySQL Full-Text indexing and Search. • Use Full-Text search server
    • 7. MySQL Full-Text search • http://wordpress.org/plugins/wp-cjk-fulltext-index/ • It improve the searching speed and result relevancy by using MATCH AGAINST than LIKE function • Use Full-Text index http://dev.mysql.com/doc/refman/5.0/en/fulltextsearch.html
    • 8. Full-Text Search SQL Example Normal Like Search : WHERE (post_title LIKE '%morbi%') OR (post_content LIKE '%morbi%') Full-Text MySQL Search : WHERE MATCH (post_title,post_content) AGAINST (’morbi');
    • 9. Pros and Cons MySQL Full-Text Indexing • Pros • Can be used in Shared hosting • No need to install extra search server • Cons • Still slow with very large data • Not featured rich like Search server
    • 10. And a very good news
    • 11. WordPress 3.7 has better search • Please upgrade your WordPress now. Relevancy is added in the search of WordPress 3.7 • Official Note from WordPress 3.7 release : Search results are now ordered by how well the search query matches a post, instead of ordered only by date. For example, when your search terms match a post title, that result will be pushed to the top.
    • 12. Difference in Search SQL • Wordpress 3.6 WHERE ((wp_posts.post_title LIKE '%morbi%') OR (wp_posts.post_content LIKE '%morbi%')) ORDER BY wp_posts.post_date DESC • WordPress 3.7 WHERE ((wp_posts.post_title LIKE '%morbi%') OR (wp_posts.post_content LIKE '%morbi%')) ORDER BY wp_posts.post_title LIKE '%morbi%' DESC, wp_posts.post_date DESC
    • 13. Still, It uses like operator of SQL
    • 14. Why full text search engine • Provides more relevant result. • Uses a ranking algorithm to quantify how strongly a given record matches search keywords. • Fast indexing • Search is fast compared to default MySQL search and MyQL Full text indexing • Allow to use special operators like OR or NOT in search
    • 15. Popular Full text search engines • Apache Solr ( http://lucene.apache.org/solr/ ) • Elastic Search ( http://www.elasticsearch.org/ ) • Sphinx ( http://sphinxsearch.com/ )
    • 16. Why Sphinx ? • Easy to setup and use • Good documentation • Used by many big websites like Craiglist, Groupon, Metacafe etc • My personal choice
    • 17. Server Requirement • Must have server with SSH access • VPS or Dedicated server is recommended
    • 18. Installation of Sphinx For Mac ( using Homebrew) brew install sphinx –-mysql For Windows / Ubuntu / Debian / RHEL/CentOS http://sphinxsearch.com/downloads/release/
    • 19. WordPress Plugin WordPress Sphinx Search Plugin http://wordpress.org/plugins/wordpress-sphinx-plugin/
    • 20. Two main components When installed sphinx, two application called indexer and searchd gets installed. • Indexer This component of Sphinx is used for indexing the data. • Searchd This is a search daemon which returns of the document id of matched search results.
    • 21. Installation
    • 22. Now setup Cron Job Note : Delta index is a small temporary index above main index.
    • 23. The boring installaion is done ! YaY
    • 24. To run indexer and searchd Manually • To run indexer manually /usr/local/sphinx/bin/indexer --rotate –config /<path of wordpress>/wpcontent/uploads/sphinx/sphinx.conf wp_delta wp_main wp_stats • To run searchd manually /usr/local/sphinx/bin/searchd --config /<pat of wordpress>/wp-content/uploads/sphinx/sphinx.conf
    • 25. Now let’s look at the result of all the hard work
    • 26. Normal WordPress search result
    • 27. Search result after using Sphinx
    • 28. Doh! This guy is done with his boring talk  Listening to next person is always boring. To make it exciting you’ve to do it yourself Thank you! Any Questions ?