How to highlight search terms without plugin

Add these 2 functions to your functions.php function search_excerpt_highlight() { $excerpt = get_the_excerpt(); $keys = implode(‘|’, explode(‘ ‘, get_search_query())); $excerpt = preg_replace(‘/(‘ . $keys .’)/iu’, ‘<strong class=”search-highlight”>\0</strong>’, $excerpt); echo ‘<p>’ . $excerpt . ‘</p>’; } function search_title_highlight() { $title = get_the_title(); $keys = implode(‘|’, explode(‘ ‘, get_search_query())); $title = preg_replace(‘/(‘ . $keys .’)/iu’, ‘<strong class=”search-highlight”>\0</strong>’, … Read more

How to create live autofill search?

The following uses jQuery UI Autocomplete, which has been included in WordPress since 3.3. (I’ve borrowed the format from @Rarst :D). It’s still not precisely what you’re after, but gives you a good starting point. The following uses a the basic jQuery UI styling, but you can use the one that’s currently worked out on … Read more

how to limit search to post titles?

Here’s a filter that’ll do the trick. Drop it into your theme’s functions.php or a plugin. /** * Search SQL filter for matching against post title only. * * @link http://wordpress.stackexchange.com/a/11826/1685 * * @param string $search * @param WP_Query $wp_query */ function wpse_11826_search_by_title( $search, $wp_query ) { if ( ! empty( $search ) && ! … Read more

Solr vs. ElasticSearch

Update Now that the question scope has been corrected, I might add something in this regard as well: There are many comparisons between Apache Solr and ElasticSearch available, so I’ll reference those I found most useful myself, i.e. covering the most important aspects: Bob Yoplait already linked kimchy’s answer to ElasticSearch, Sphinx, Lucene, Solr, Xapian. Which fits for which usage?, … Read more