Relevanssi – Better search for WordPress

Let’s face the facts: WordPress search sucks. The search lists the results in date order, latest first. This is rarely useful. It also searches for the exact query, nothing less and nothing more. In particular, if you’re using WP as a content-management system instead of just running a small blog, the basic search will leave you in trouble.

Most replacements or enhancements don’t really fix what’s broken. wpSearch does, but it has other issues. At least for me, it causes pretty serious hangups when editing posts, the indexing of a new post is very slow when you have ~900 posts in the database. So, it’s not ideal.

Enter Relevanssi (Finnish for ”relevance”), a new WordPress search.

This is where the Relevanssi home page used to be; nowadays go to There you can find everything you want, including the new and great Relevanssi Premium.

Relevanssi in action

Comments below are for historical purposes. I’ve closed the commenting. Relevanssi Premium customers get support at the Relevanssi site, the rest can use the support forum.

343 kommenttia – uusimmat ensin, eli kysymykset löytyvät vastausten jälkeen

  1. Mikko Saari

    Peter: I’ll add that to the list of features to add. I don’t think it’s a big change.

  2. Tom Campbell

    I had installed Relevanssi, but it overwrote the javascript for the slideshow plug-in I’m using (rektslideshow). So, sadly, I’ve had to disable and delete Relevanssi. If you fix this issue in the future I’d be interested in using your plug-in, but the slideshow on my site is essential.


  3. Peter

    Thank you for an AWESOME plugin. A nice mod would be to allow indexing of draft posts too for the purpose of Admin search. I know the hack isn’t difficult to make, I’m just wary of upgrades!

  4. me

    Yeah, it’s just that my theme didn’t have a native search.php and when I copied one over from another theme I completely broke the search function. So I’m still trying to work that one out.

  5. Mikko Saari

    Yes, you should definitely use excerpts on search results pages. Your search results template probably uses ’the_content()’ to show the posts, replace that to ’the_excerpt()’.

  6. me

    Some of my pages are very long and thus the search page turns out very very very long. Is there a way to show only the snippet and not the entire page?

  7. Graham Armfield

    Hi Mikko, thanks for the great plugin – I’ve started using it on a couple of sites now, but I’ve run into problems with the most recent one for a client.

    On my Search page I’ve used the technique you described to report on the number of posts meeting the search criteria. The number here is much higher than the actual results then reported below. My default setting is for ten items to appear on each page. I carry out a search on a term that is on many pages and the total figure records 21 found. The first page of results actually shows 2, the next shows 1 and the third shows 1 = 4 altogether. If I deactivate Relevanssi I get the full 21 pages so they are being suppressed somehow – but I’m not sure why.

    Having read through the comments I think the issue is maybe linked with excerpts. I have been using the Page Excerpts plugin which adds excerpts to pages – a useful feature. But I have disabled this plugin and the results do not change. I have disabled all other plugins and still the same. Interestingly if I disable the Custom Excerpts option of Relevanssi all 21 results do appear. But ideally I want to use the Custom Excerpts as it features the text highlighting etc.

    My search.php does use the_excerpt() and I’ve also tried relevanssi_the_excerpt() but still no joy.

    Have you any further suggestions?

  8. William Tcherust

    Thanks Mikko!

    I will be looking forward to see this feature in action!

    Regards 🙂

    P.D. I am not a programmer, but if there’s anything else I can help you with, please let me know.

  9. Mikko Saari

    Yes, that’s possible and something I’ll be adding in the future.

  10. William Tcherust

    Hi Mikko,

    I’m using your plugin and I really like its advantages, and now I only would like to ask if it is possible to highlight keywords someone typed in google or yahoo when they enter my site. For example, if someone types in google relevanssi search, I would like to have those words highlighted in the landing page.

    I would really use some help with this one. Thanks in advance!

  11. Mikko Saari

    Enable the custom excerpts. If you see custom excerpts, Relevanssi is working.

  12. rezaur

    hello, Is there anyway i can be sure that the search result is produced by your plugin. my site is on norway language. pls help me

  13. Tino Tkalec

    Well, relevanssi is really powerfull (congrats on that :)), and I use it’s search inclusion of custom
    fields and tags and all that, but my customer doesn’t want it to return posts sorted by relevance, but by title. I’ll look into your FAQ. Tnx

  14. Mikko Saari

    Yes, using query_posts() will not work with Relevanssi. See ”Sorting search results” in the Relevanssi FAQ for a one way to do it. I think you can also pass the the orderby and order parameters in hidden input elements from the search form (I haven’t tried that, though). Why’d you want to lose the real power of Relevanssi — ordering search results by relevancy — is something I don’t get, though. If you don’t want want to order the results by relevancy, you get much better performance by just deactivating Relevanssi.

  15. Tino Tkalec

    Hi. I really enjoy using your plugin… But I run into some problems…
    Is there any way to sort my search results by title of the post in ASC order?

    If I add this code to my loop page, Relevanssi doesn’t work anymore, but posts are ordered:
    global $query_string;
    query_posts( $query_string . ”&orderby=title&order=ASC” );


  16. Chuck Littau

    Thank you for such a great plugin! I would like to make a new feature suggestion. A feature I would love to see added would be the ability to redirect 404 OR 301 ”file not found” errors to the search engine as search terms. For example if I had a tag on my website named ”Piano Humidity Swings” and I deleted the tag ~ yet Google still had the tag indexed and when people clicked on the search result from Google they would be redirected to a search result using those terms. Like this search:

  17. Mikko Saari

    Actually, it’s not in the FAQ. Sorry. It’s in the installation instructions, though, and reading those is highly recommended with any plugin.

    Anyway, here’s the answer: there is no Relevanssi search box. Just use the standard search box.

  18. Mikko Saari

    How about reading the FAQ that comes with the plugin? This is just the first thing answered in it.

  19. Joe

    I feel stupid. How do I get the Relevanssi search box to show up in my theme? Is there supposed to be a widget?

  20. Mikko Saari

    Sorry, I don’t have any idea what could cause this.

  21. Joy

    Is there any reason that your search wouldn’t find a normal page? (post type of ”page”)
    Apparently changing the way custom posts are defined affects whether pages are found. I didn’t try to define my custom post types differently, but using 2 different plugins to do it, I got 2 different results. But why would this affect normal pages (and normal posts)? Answer that and it will probably be the key to the custom post problem I’m having.

  22. jaffa

    Thanks for your reply Mikko. Hope the release isn’t too far away.

    Keep up the good work!


  23. Mikko Saari

    Joy, that sounds complicated and I’m running out of ideas here.

  24. Joy

    The ”Respect exclude_from_search for custom post types” setting is checked.
    In both More Types and Ultimate Post Types, it is set to be searchable. (It occurred to me that this is the one setting that they framed in the negative and the plugin author could have got it backwards.)

    The exclude from search setting for my custom post should not affect whether a normal page is found or not, and that’s part of what I’m seeing.

  25. Mikko Saari

    Is it possible that your custom post types are set to ”exclude_from_search”? What’s the status of your ”Respect exclude_from_search for custom post types” setting?

    If the plugins just help you define the post types, you could try defining the custom type manually.

  26. Joy

    I tried your fix you mentioned in comment 298, but I got the exact same results as before.
    Is there anything I could print out to help debug?

  27. Mikko Saari

    Correct — though when updating the plugin, it should do the disactivate-activate thing automatically and create the tables.

  28. Mike

    Hi there!

    First of all: Grats! This is a great plugin.
    It worked all the time very well. Now I did an update to WP 3.1 and now i get the following DB error on publishing a post:

    WordPress database error: [Table ’sportlive-wp.wp_relevanssi_excerpt_cache’ doesn’t exist]
    DELETE FROM wp_relevanssi_excerpt_cache WHERE post = 706

    The solution:
    Just deactivate and activate the plugin – then Relevanssi search will work again without troubles.
    Don’t know why the table was missing after the update. Now the table exists in the database.

    Maybe someone will need this hint too 🙂


  29. Mikko Saari

    Jaffa: Not right now, but I already have a Multisite-compatible version written, it just needs a bit more testing.

  30. jaffa

    This seems like a great plugin, just what I need. One question though, is it compatible with WPMU?

    (I hope so)



  31. Mikko Saari

    Relevanssi will show the best excerpt from the post and comments. In this case it’ll be the part that has the word ”possible” most times – that can be in comments or in the post.

    If you want to force everything to appear, show the whole post =) There’s no way to get several excerpts from one post.

    Relevanssi doesn’t know which part is author and which part is just text, so marking it is not possible.

  32. Jo

    I am using relevanssi on my site now, but my client is asking alot in terms of how the results are displayed.

    They want their site to be more about the comments, so want all the comments to appear in the search results if they contain the searched word. But they’re not currently. For example the word ‘possible’ appears multiple times in one post and in many different comments in that one post. However, it only appeared as one entry in the results when searched for but when you clicked through the word possible was highlighted many times all the times its mentioned in the comments. Is there a way have all the results of the word to appear, regardless if they are on the same post.

    Also, is there a way to highlight the difference between an author and general text, just bold or something.

    This such a great plug-in, thank you.

  33. Mikko Saari

    Looking at your site, I have no idea what’s wrong. It would require a closer look to figure out. Might have something to do with plugins you’re using or something else. Let me know if you’re interested, I can take a look, but it’ll cost you.

  34. Keith Perrin

    OK The database was already indexed when I asked the question. Here is the web site: Under AUCTIONS you will see there is a listing for a Gold Maple Leaf. Try a Search for ”Maple”. No result. Regular WP search doesn’t see these entries and nor does Relevanssi. Are these custom fields? If they are, how do I figure out what they are called?

  35. Mikko Saari

    Please read the FAQ, what you’re asking is the first item in it. Relevanssi doesn’t provide a search widget, because it uses the regular search widget. Make sure you’ve indexed the database.

  36. Keith Perrin

    Building a new web site (not the one mentioned above) and installed Relevanssi and I confess I don’t get it. Is there supposed to be a Relevanssi Search widget? The regular WP search widget is there but it doesn’t behave any differently than it did before I installed Relevanssi. What am I missing?

  37. Mikko Saari

    Bruno: Internal Server Error tells me nothing of what’s wrong, but since there’s evidence that Relevanssi works with WP 3.1, it’s probably something in your setup. Checking server error logs might give a clue of what’s wrong.

    Joy: I’m fairly sure the problem is caused with permissions. The way Relevanssi handles custom post type permissions is something of a hack, and that’s probably what’s happening here.

    Find this in the code (lines 1148-1151, I think):

    $cap = ’read_private_’ . $type . ’s’;
    if (current_user_can($cap)) {
    $post_ok = true;

    and replace it with just:

    $post_ok = true;

    That might fix your problem.

  38. Joy

    Followup: After eliminating all the plugins I could, I found that changing from ”More Types” plugin back to ”Ultimate Post Type Manager” allowed the Relevanssi search to work. This is odd because I switched so that the ”Query Multiple Taxonomies” plugin would work.
    I created the posts with a custom post type defined with Ultimate, then had to switch to More Types (I defined it the same). At the time of building the index for Relevanssi, I could edit, display and everything all the custom posts I made. Relevanssi reported them correctly in the number of documents, and I saw the terms from them in its table. It just didn’t return them as results.

    So, with More Types active a search for a word that is in the content of a page and in the title of 2 custom posts shows just the page. When I switch to Ultimate, the same search shows just the 2 custom posts and not the page.
    Another example with word in title of regular posts and content of page and custom posts: with More Types I get the regular posts and the page. With Ultimate I get the regular posts and the custom posts, not the page.

    I don’t know what’s going on, but I need to use a plugin for custom posts and I’m getting such mixed results.

  39. Joy

    Hi, I am just trying your plugin on a test stie with WP 3.1 and Relevanssi 2.7.3. I switched to the TwentyTen theme to see if that was the problem, but same result: it’s as if the plugin isn’t there. I have mostly the default settings, index everything, use AND and fuzzy when straight gets no hits. I built the index and it shows 482 documents, most of which are a custom post type.
    When I search for something I know is in my regular posts, it finds it and displays (with highlight). When I search for something in the custom posts, I get no hits. I looked in the database and the term I searched is in the relevanssi table 10 times.
    I thought it might conflict with the plugin ”Query Multiple Taxonomies”, but I deactivated it and Relevanssi still didn’t find my search term.

  40. Bruno Sacco

    I’m getting a:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    Everytime I search a anything. Any ideas about this?

  41. Mikko Saari

    How? It works on my test system, but I haven’t tested it thoroughly.

  42. Mikko Saari

    Rich, I’ll try to get something done and get some code for you to test, but it’ll take a while, I’m a bit busy with other projects just now.

    Everybody who wants a dropdown category box: download 2.7.3 and see the FAQ, you’ll find instructions there.

  43. Rich

    Hi Mikko,
    Yes that would be great, I already have tags and categories for the geeric terms, it’s just that people seem to type it into the search box. If you could give me the code to do what you suggested, that would be great. even the first couple of thousand results would be OK. Better than 8 thousand! or any amount for that matter.


  44. Mikko Saari

    Blogie: What you want is already possible. Just add the dropdown to the search form. Make sure the name of the field is ”cat” and the values are category numbers. That’s category restriction for you.

    Rich: Yeah, Relevanssi can be a problematic with large databases. Relevanssi should display as many posts as is specified in your WP settings. However, it has to process a very large number of documents to get to that small amount of posts. The problem is, Relevanssi won’t know which posts are the most relevant unless it checks all that match the query. I don’t really have a good solution for that kind of problem – generic searches can be a problem.

    Would you be satisfied with a setting that would restrict the search to first couple of hundred matches, chosen somewhat randomly (basically whatever order the database gives them)? That way the search wouldn’t find every document, nor would it necessarily find the best match, but if the search query is generic enough to produce many hundred results, finding the single best result might not be that important. When the search is more specific, it would find all results.

  45. Blogie

    Hi there. I’d like to know, is there a plan to expand the functionality of the plugin to allow for advanced searching? For example, I’d like to have a dropdown box that will have the categories in it, so that a user can provide the search keywords and then choose a category from the dropdown menu to make the search more specific.

    Excellent plugin!

  46. Rich

    Hi Mikko,
    I have a rather large site with tens of thousands of posts, Relevanssi is an excellent plugin, but perhaps too excellent (bet you never had anyone say that before). The problem I’m faced with is relevanssi sometimes returns thousands of results, especially when the search query is rather generic, and it’s wreaking havoc on mysql. I was wondering if there is a way to add some code to make relevanssi only get/display a given amount of posts?

    Can you help?

  47. Mikko Saari

    DS: The script has timed out hours ago =) It won’t take many minutes to time out. Then you should just click ”continue indexing” again and again until you have everything indexed.

    Cristhian: Is ’a’ in your stopword list? If not, make it a stopword and see what happens.

  48. Cristhian

    Hi Miko, first of all, sorry for my bad English.

    I have a site (in Spanish) where I installed Relevanssi. Works perfect, the results are very relevant, but there is one problem. When I search something with the word ”a”, my site is blank. If I disable Relevanssi, the problem is solved. Any idea what might be happening?

    For example: -> This page don’t work, because contain the ”a” word. -> This works. -> Dont work angain 🙁

    Thank you very much for your help sir, I promise that I will donate something.

  49. DS

    Hi there 🙂
    How to know when indexing is over?
    I have 85,594 articles in database… after more than 24 hours indexing is still running
    Thanks in advance

  50. Mikko Saari

    Yes, the index updates automatically.

  51. KB

    Just a quick one – is the index self updating? Or can it be?

    As my client will be managing their site so if they add / edit or even delete posts/pages will they always need to re-build the index?

  52. KB

    Hi Mikko,

    WP and all my plugins are up-to-date. What I did find is it was a particular page that had a shortcode from the ”theme my profile” plugin. Once I excluded that page from the results – no more errors. 🙂

    Still can’t figure out why No highlighting…
    I did have some code in my theme/functions.php which overrides the default ”wp_trim_excerpt”. Even when I took that out I still go no highlighting. I then had a look at the ”wp_trim_excerpt()” in wp-includes/formatting.php. Noticed that it was doing a ”string_tags”. Also tried commenting that out – but still no joy. Perhaps my settings in Relevanssi are wrong?

    My settings in Relevanssi:
    Create custom search result snippets: ticked
    Length of the snippet: 400
    Show breakdown of search hits in excerpts: ticked
    The breakdown format: %total%, %body%, %title%, %tags%

    First, choose the type of highlighting used: background color
    Highlight query terms in result titles too: ticked
    Highlight query terms in documents: ticked
    Highlight query terms in comments: no tick

    Background color for highlights: #ffaf75

    Thanks again

  53. Mikko Saari

    No idea, what’s the plugin doing on that line? Try turning debugging on and see if you get anything helpful… Actually, looking at the changelog, updating to the latest version of the plugin will probably fix it.

    No highlighting… strange, I can’t say much except that it does work for me. You do get the custom excerpts? And no HTML code gets added to the excerpts for the highlighting? And you have no plugins that mess with the excerpts?

  54. KB

    Hi Mikko – great plugin.

    But I have a couple of questions.

    Q1. Every now and then I run a search and I get

    Fatal error: Call to undefined function wp_reset_vars() in C:\wamp\www\ax10sites\lotc\wp-content\plugins\theme-my-profile\theme-my-profile.php on line 210

    Yes – its from a different plugin BUT if its a conflict then I’d expect to see this message for every search. But only happens randomly. EG i used phrase ”Renaissance East”. I tracked it and was the ”East” that triggered it. I noticed that ”West” and ”North” also trigger the error. Is there some keywords that are known to trigger this behaviour?

    Any clues?

    Q2 – I get no highlighting
    I’ve ticked on Custom Excerpts, My search template is using the_excerpt(), I’ve tried text color, background color but nothing comes out.


  55. Mikko Saari

    Adjust your sitemap generator so it’s not including search results pages. Google Webmaster Guidelines say you should prevent Google from indexing your search results:

    ”Use robots.txt to prevent crawling of search results pages or other auto-generated pages that don’t add much value for users coming from search engines.”

  56. Bruno Sacco

    Let me explain it to you … I have the Google XML Sitemap Generator running in the background, so ANY pageview in the sites gets submited to Google.

    Well I will just block those keywords in another way, but thanks a lot its a great search for WordPress.

    Sorry for the problem.

  57. Mikko Saari

    Well, you can’t prevent someone from typing words to the search box. If you’re having problems with Google indexing unpleasant queries, you should add ”noindex” directive on your search results pages (indexing search results is apparently against Google rules in any case).

    I guess I just don’t see what’s the problem with someone searching for rude words, if those words don’t appear on your site.

  58. Bruno Sacco

    There is a way to BAN words … no STOPWORDS I mean banned search, for example I get ”Justin B penxx online” … I have Justib B, but no pexx in my site. There is a way to still using the OR search, get some words banned, or ban the hole search if it contains that word.

    Google is indexing some strange results in my site(”Litle girls doing xxx, etc…”), and some words are not acepted in our editorial reviews.

    Thanks great work.

  59. Frank

    I’ve found that the newest version doesn’t highlight queries on entries after clicking on search results. This was ok before the latest release.
    Anyway this is a greta plugin I really enjoy. Keep up the good work!

  60. Mikko Saari

    Ok, I’ll have to check it. It’s probably a line feed issue. I’m going to do a new version fairly soon.

    What comes to multiple words, you can do it either way, with quotes or without, depending on if you want exact phrase or not.

  61. jan

    synonyms still don’t work, if i can help you find out what the problem is, feel free to hit me up via email

    and just the record, what if synonyms contain multiple words – are quotes necessary?

  62. Chris Beaman

    Just wanted to say I’m really impressed with the ongoing support and prompt, helpful responses. Great job!

  63. Bruno Sacco

    Can you please add an option to NOT index 2 keyword words? or 3 … let do it an admin option.
    Thanks nice work!

  64. Mikko Saari

    It should work with one per line.

    synonym = word
    synonym2 = word
    synonym3 = word

    That should do it… Hmm, Relevanssi expects \n linefeeds, perhaps some systems put something like \r\n there. That might cause it, if that syntax doesn’t work for you. Well, that’d be easy to fix.

  65. jan

    no matter what i try, the synonyms don’t work for me. using mysql 5.1

    maybe you can give an example for multiple synonyms: is it one per line, seperated by comma? (not that i didn’t try these)

  66. Tomas Kapler

    Ups, fatal problem with wp_debug to true – when saving post, this appears:

    Notice: Undefined variable: post_type in /httpdocs/wp-content/plugins/relevanssi/relevanssi.php on line 207

    Notice: Undefined variable: post_type in /wp-content/plugins/relevanssi/relevanssi.php on line 207

    Warning: Cannot modify header information – headers already sent by (output started at /wp-content/plugins/relevanssi/relevanssi.php:207) in /wp-includes/pluggable.php on line 897

  67. Tomas Kapler

    small bug with wp_debug=true
    Notice: Undefined variable: wp_version in /httpdocs/wp-content/plugins/relevanssi/relevanssi.php on line 2845
    (plus stil that error message when activatin: ”The plugin generated 1002 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin’)

    it would be great, if there could be some easy way to import stop words (at least make it textfield and accept comma etc. delimiter) and the same with bulk remove (i do not need there any english stopword). And maybe export/import of all settings would be fine as well as at other plugins with so many options.

    P.S.: for me it was hard to notice the difference, as i got filter on get_excerpt (i have just added condition to solve it), i just wonder that you write about ”did you mean” – i have not noticed anything like this. Also it does not search by categories.(not names, nor their descriptions), it works probably for tags

  68. Jens Wedin

    Yes, I run 5.0.67.

    About the synonyms, is it one per row or just a comma between?

  69. JF Lussier

    Hi Mikko,

    thanks for the clarification on the indexation of private pages. I hadn’t realized I was logged in when a private page appeared in my search results. Of ocurse your explanation makes a lot of sense.

    As to the lagging problem, I was going to give you more details about my W3TC setup this morning, but now the problem appears to have gone! I had already installed the latest Relevanssi update earlier on, so either today’s update fixed the problem or there’s something I decidely don’t understand.

    One way or another, everything works fine now.

  70. Mikko Saari

    Sure, I can fix that. Next version will fix it. If you want to fix it now, change ”manage_options” on line 100 to ”manage_categories”.

  71. Will Abbott

    Hi there

    Great plugin. Is there a way to allow the ’editor’ roler to be able to see the User Search’s beneath the dashboard menu item? At the moment it limits to admin only?

    Thanks in advance

  72. Mikko Saari

    Jens: are you running MySQL 5? The search stats page uses a MySQL feature that’s not present in MySQL 4. That might cause the problem.

    Yes, synonyms work like that, as long as you have OR set as the implicit operator. If you want it to work both ways, you need to enter both.

    JF: I’m running W3 Total Cache with Relevanssi on one of my sites, and I get no problems at all — if I can’t reproduce the problem, I can’t fix it. Send me an email (mikko @ about your W3TC settings, perhaps there’s some setting that’s causing the problems.

    Relevanssi indexes private posts and pages on purpose, but when the search results are compiled, each document is checked to see if the current searcher has access to the document.

    So, it’s a glitch if a private document shows up in search results for someone who should not see it, but not a glitch if it’s indexed. Also, private documents do have an ID (they have to, otherwise they couldn’t be identified in the database), but there should be no need to exclude them from index if Relevanssi works properly.

  73. JF Lussier

    Hi again Mikko,

    I just want to update on my post of a few days ago about the highlighting option that ’lags’ by highlighting words from the two most recent searches.

    After some testing, I have pinned the problem down to some sort of incompatibility with the cache plugin W3 Total Cache. Strangely, the problem does not only concern lagging in the highlighted search results keywords but also some lagging in the way Relevanssi settings are taken into account. For example, I ended up with highlighting in titles still activated even after I had turned off highlighting and flushed the cache.

    W3 Total Cache is an extremely popular cache plugin (274K downloads from the WordPress site) and is gaining on WP Supercache in popularity. It would be very nice if you could make Relevanssi work well with W3 Total Cache.

    I also noticed another minor ’glitch’ : Relevanssi indexes private pages by default, even when set to index ’All public post types’. I might be missing something, but it does not seem appropriate. And since private pages don’t have an ID, they can’t be excluded from the index.

    Thanks for your great work!

  74. Jens Wedin

    I also have a question about synonyms. If I have a custom field where I written ”whisky” and I want a synonym as ”whiskey” would I add it like this


    and can I do it in reverse also


  75. Jens Wedin

    Hi again, ok, I will check if I can increase the memory at my host.

    I have another question, in the search log it sais


    What is this?

  76. Mikko Saari

    I think I can fix that, yes, but it requires an update to Relevanssi.

  77. Jo

    I have installed your plug in and its working fine, but I have another plug in that stops swear words appearing in the comments (WP Content Filter) but the swear words are appearing in the results. Is there a way I can prevent this?

  78. Alok Sharma

    Hi Mikko,

    Just one small feature request. Can you please make the following input fields into text area as they are very small to see the contents inside them.

    – Don’t log queries from these users
    – Restrict search to these categories and tags
    – Exclude these categories and tags from search
    – Exclude these posts/pages from search
    – Custom post types to index
    – Custom fields to index
    – Custom taxonomies to index

    Although, I only use the last two fields but making other fields as text area will be useful if other people are entering lot of data in it. Or may be you can make it such that the text area will shrink (to single line) or expand (to multiple lines) as any data is removed or added in it.



  79. Mikko Saari

    If you want recent posts first, that’s simple – just disable Relevanssi. Basic WordPress search does recent first, and most of the time the results are unsatisfactory. That’s why I created Relevanssi in the first place, and I don’t have much interest in providing unrelevant results. You can’t have posts ordered by both recentness and relevancy at the same time.

    That said, read Relevanssi documentation for a way to let the user restrict searches by date. There’s also way to do the basic sort by date, but you can’t make it default.

  80. Evan Jacobs

    Hi Mikko!

    I really like your plugin (we use it on, but i’d like to request a feature in your next version.

    Would it be possible to have an option that places more emphasis on recent posts? Or perhaps a sorting engine that allows you to display results by most recent first?

  81. Mikko Saari

    Yes, that’s the only way to do it.

  82. Alok Sharma

    Hello Mikko,

    I am using a plugin called Simple Fields especially for Repeatable fields. For e.g. if I have the following fields:


    Then, I will be able to add multiple entries for the same. The plugin simply suffixes the no at the end of the field key for e.g. title_1, description_1, url_1, title_2, description_2, url_2, title_3, description_3, url_3 and so on, depending on the no of group entries I have added.

    The only issue is that how do I add these fields to index because I don’t know that what will be the maximum no of group entries that I will create per post.

    If I am not wrong, the only way that I see is adding up to 10 or more field groups like title_1, description_1, url_1, title_2, description_2, url_2, title_3, description_3, url_3…..title_2, description_2, url_2, title_10, description_10, url_10.



  83. Mikko Saari

    Ask your ISP to give you more memory. You’re running out of memory when searching for very common words.

  84. Jens Wedin


    Great plugin! I have a problem that I get this error message for certain queries

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 45 bytes) in /home/web30214/domains/ on line 845

    This gives an error

    But not this

  85. Mikko Saari

    Yes, I’ve had reports. Well, your report is somewhat unique, the usual story has all highlights ”lagging” one page behind. There have been reports of highlights appearing in odd places like menus, too.

    It has something to do with caching or how the referrals are handled. Somehow the browser is giving WordPress wrong referral information. As long as I’m unable to reproduce the problem on my system, I’ve got little idea on how to fix it.

    You might try dumping various system variables to see what they contain.

  86. JFL

    Hi Mikko, when you say older problem, do you mean other people have reported this phenomenon in the past?

    Do you think it can have something to do with my cache plugin? I use W3 Total Cache, but it is configured not to cache search results so pages, in theory, it shouldn’t cause any problems.

    Do you have any clue in what direction I should look?

    Thanks in advance!

  87. Mikko Saari

    No, this is an older problem I haven’t been able to reproduce on my blogs.

  88. JFL

    Hi Mikko,

    I just installed Relevanssi but a strange phenomenon occurs. No matter the settings I choose, the search results highlight this :

    In titles : the word I just searched
    In the content area of each search result : the word from the previous search

    So, if I need to search twice in a row with the same word in order to get the searchword highlighted in both the titles and the content. Otherwise, the content areas are one step behind.

    Could this be a bug with the latest release?

  89. Sascha

    Hi Mikko,

    unfortunately the usage of 2.5.5. didn’t solve the issue. I will contact the MapPress developer and ask him to have a look at it. Let’s see.

    Thanks for super-fast answer


  90. Mikko Saari

    Try Relevanssi 2.5.5, the latest version – that might solve the problem. If it doesn’t, however, I’d say it’s a bug in MapPress and you should ask the makers of that plugin for a fix.

  91. Sascha

    Hei Mikko,

    first of all thanks for the awesome plugin. It ”would” provide exactly what I need for my local project. (Restaurants, Bars etc, in my home town)
    Unfortunately I also want to use the MapPress-Plugin. While not having any issues with the indexing, search is totally broken when activating both plugins.

    Errormessage: Fatal error: __clone method called on non-object in /www/htdocs/w00c1e1c/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_pro.php on line 302

    See live:

    Do you have any clue what the issue might be? The plugin would be far to valuable to ditch it, but map-support is even more important for this project.

    Kiitos for you help in advance 😉


  92. Mikko Saari

    Does it work if you disable the pagination plugin? As such, Relevanssi shouldn’t care how the comments are paginated, so it should find them, but of course Relevanssi won’t know on which page the comments are, so the search result shows only the actual post page (because Relevanssi doesn’t index stuff by comment, but by post). Do you get hits for comment content on later pages?

  93. seklein

    Can’t quite figure out how to get your plugin to search all the comments in my website. Because there are so many comments, I have a pagination plugin. Seems Relevanssi can’t search past the first page of comments. How can I get it to search and highlight all the relevant comments?

  94. kele

    Hi Mikko

    Exclude these categories and tags from search:

    Thats what i did try and for some reason it doesnt seem to do anything. I still see custom post types from that category. I even checked in the relevanssi table and the specific doc in question isn’t in there, yet it still appears in the results.

    Only when i add this to my functions.php does it actually exclude results from the category.

    function SearchFilter($query) {
    if ($query->is_search) {
    return $query;

  95. Mikko Saari

    Kele, that filter is for advanced hacking. For excluding categories from search, just use the exclusion setting in the Relevanssi options.

    BeN, I actually don’t know how Relevanssi handles posts with two categories. I’ll have to think about it.

  96. kele

    plugin version 2.5.4

    Just wondering what this line on 842
    $query_restrictions = apply_filters(’relevanssi_where’, $query_restrictions); // Charles St-Pierre

    is supposed to do? trying to exclude categories from search and it’s not working.


  97. BeN

    Hi Mikko, thanks for your help.. wat i want to do is this.

    Search for a term and limit to certain cats… i want to put on 2 combobox a list of categories, 3 cats on 1 and 3 on the second… i already did this and using Javascript y pass the parameter cat=10,20 taking the cat number from each combobox…,

    Is posible get the posts that have that 2 cats? i think relevanssi now returns all the posts from that 2 categories and maybe some posts of the results only have marked one from the 2 categories, i want the posts that have the 2 cats marked on the post. Is posible this? do you understand me? sorry by my english

  98. OJT

    Thank you for the plugin. This will help on our projects

  99. Mikko Saari

    BeN: Yes, that should do it. Have you tried setting it from the plugin settings?

    Kerasiotis: Nice, thanks! I’ll have to take a look. One thing that may be a problem: what if someone searches repeatedly for obscenities? Especially in a smaller blog, it doesn’t take much searching for one user to fill the widget with whatever they please.

  100. BeN

    Hi Mikko, i have a question… how i use the feature of limit to certain categories,

    in this way? cat=23,24,25,-12

    i am trying in this way and the results are always the same

  101. Kerasiotis Vasileios

    I created a simple widget that queries relevanssi logs and displays the search statistics as a widget in any sidebar. For custom display you can create another function in the relevanssi plugin file as instructed in the readme file of the widget.
    You can download it from here: ( direct link to file:

    I hope you like it. Give me some feedback too

  102. Mikko Saari

    Dave’s Live Search should work, there was a problem but the bug was found and possibly fixed, too. I don’t know, because I don’t use it (or any other Ajax search plugins) myself.

  103. Tutor

    Dear Mikko

    Great work and I look forward to fully understanding your plugin from a user perspective. Please could you advise on any suitable ajax search that works well with your plugin.

    I look forward to hearing from you.

    Best wishes

  104. Mikko Saari

    Well, Ludovic, I would recommend using AND, because it removes lots of chaff from the results. The boost factors are a matter of personal needs and how important your titles are to you. If you have, say, product review site where the name of the product is the title of the post, you want a strong title boost, otherwise the default value (or even less) is fine.

    Your problem stems from the fact that ”niche” is a very common word in your blog (often top 25 words are not meaningful words like that) and thus very insignificant in the eyes of Relevanssi. You probably shouldn’t have made it a stopword though, so remove it from stopwords (you can do that easily with the latest version) and re-index.

    You really can’t make the niche marketing posts stand out more, if the word appers in just about every bost. However, if you increase the title boost (a lot, if necessary), you can probably make the posts with the word in title jump up.

    Also, you can use phrase searching, wrap the search query in quotes (”niche marketing”). That’ll force the words next to each other.

  105. Ludovic

    Also, I have other 1,000 posts.
    I tried search for the ”Niche Marketing”

    However, a post with the title ”Video Marketing with youtube” comes up.
    Then below, other irrelevant post.

    You would find relevant post by the time you get down to the 5th or 6th post.

    Right now my settings are:
    Default operator for the search? AND – require all terms
    When to use fuzzy matching? When straight searches gets no hits.

    I have no tags or comments in my wordpress, but title I do, which i gave a 2

    Create custom search result snippets: checked
    Show breakdown of search hits in excerpts:
    The breakdown format: anything I type here doesn’t show or work like %terms%
    Indexing options:
    What to include in the index: All public post
    Index and search your posts’ categories:checked

    The word ”niche” from ”Niche marketing” was included inside the 25 most common words in the index. I removed it. And Results does not show relevant words to ”Niche marketing” until the bottom of page. How can I make sure the results on top must have the word ”Niche Marketing” exactly matched on top and not at the bottom.

    All the best,

  106. Ludovic


    Do you have any recommended settings, we should go by for optimal results?

    I would love to have your suggested settings .

    All the best,

  107. Mikko Saari

    Per, that shortcode is simply a quick way for the blog author to add some links to searches. For user search field, just use the regular search box provided in your template.

  108. Per Koustrup

    Hey, i would like to use your search plugin.
    I can get [search]something[/search] to work. but is there a way to let the user type in the ”something”?

    i would like to have a search field on my front page. can i do something like [searchfield][/searchfield] ?

  109. BeN

    Hi Mikko, i am testing and seems to work great, recently install the Wp Super Cache Plugin and the performance is awesome. The searchs are cached too…

    When we launch the site i let you know… (now is on a private production server).

  110. Mikko Saari

    Thanks for the bug fix.

    I have no experience with large databases, the biggest I have are about ~2000 posts, so can’t help you there, sorry.

  111. BeN

    Just a comment, when i was testing the plugin i get no results, always 0… i start debugging and find this…

    if ($post_type) {
    if (!is_array($post_types)) {
    $post_types = explode(’,’, $post_type);
    $pt_array = array();
    foreach ($post_types as $pt) {
    $pt = ”’” . trim(mysql_real_escape_string($pt)) . ”’”;
    array_push($pt_array, $pt);
    $post_type = implode(”,”, $pt_array);

    i change to this…

    if ($post_type) {

    //Next line
    if (!is_array($post_type)) {
    $post_types = explode(’,’, $post_type);
    $pt_array = array();
    foreach ($post_types as $pt) {
    $pt = ”’” . trim(mysql_real_escape_string($pt)) . ”’”;
    array_push($pt_array, $pt);
    $post_type = implode(”,”, $pt_array);

    Only with that change i fix the problem

  112. BeN

    Great Mikko, thanks for your help… works great…

    Also i change the strlen comp… like line 1694 to if (strlen($title) < 4) continue; because i dont
    want words of 3 chars lenght.

    Comment the line 1886 because every time i want to get into the ADmin panel of the plugin, that part takes a lot of time.

    My DB of posts have 28,000 posts… is very slow the "build index" and now i am gonna test the performance of the plugin,. Can you give me some advice?

  113. Mikko Saari

    Hans: No idea, but Relevanssi imposes no limits. It’s up to your server’s performance, pretty much. There’s no optimization, but if your MySQL server is robust…

    Beeralist: Instead of query_posts(), create a WP_Query object and pass it to relevanssi_do_query(). That might do the trick.

  114. Beeralist

    This is an excellent plugin mate – thanks very much.

    I too noticed that the plugin stopped working with query_posts() present. I was using query_posts() to control the number of search results to show on each page – basically to a higher value than the default. Is there an option in your plugin to up the number of search results to show?

  115. hans

    how much posts does this plugin can handle? more than 20k?

  116. Mikko Saari

    The date limit stuff starts at line 805. The actual restriction is at line 832. Instead of DATE_SUB, you can do simple post_date > low limit AND post_date < high limit.

  117. BeN

    Hi Mikko, great plugin… Is posible to limit the date search to a certain lapse of dates… pick the start and the end date????

    Can you give me some advice to modify maybe the plugin to do this?

    thanks a lot

  118. Poli

    Hello Mikko,

    After all that I remembered that when searching WordPress tries to first find search.php, which my set up doesn’t have, because the results are shown via index.php using the same functions as to retrieve content. So, that was the solution. I created a search.php that eliminated $posts = query_posts($query_string); separating the search from the rest of the content retrieving. I managed to keep all the stuff I wanted from index.php but now it works with Relevanssi. It seems to be pretty solid so I’m satisfied that it’ll keep that way.

    One little thing. I want to increase the number of characters to search to 3 so that users don’t retrieve practically the whole of the database when searching with just one vowel. I haven’t look at the code to do that so perhaps it’s fairly easy.

    Anyway, thanks for Relevanssi. Its use has improved the searching of the listings and therefore I’ll make a donation to it.


  119. Poli

    I’ll do that. In the email I’ll explain further.

  120. Mikko Saari

    Yes, Relevanssi can find hits in tags and custom fields. That’s very basic function and should work pretty much out of the box, with no special features.

    The problem here seems to be that the $query_string you’re using doesn’t contain what Relevanssi wants.

    Drop me an email to mikko at containing your search result template and I can see if I can make some sense of it.

  121. Poli

    The output is typical of a business directory. (name, address, telephone, etc.) The problem at the moment is that the search is effected only on the title, leaving out tags and custom fields, which are the most important. So, if a keyword is entered that exist in a custom field or tag but not in the title, the search will output nothing. Perhaps you can get a better idea going to I believe Relevanssi has the capability of doing such search.

    Unfortunately, my php knowledge doesn’t cover enough to accomplish your suggestion.

  122. Mikko Saari

    What does that function output, then? What’s in the $query_string? If it’s just a textual search query, then you need to create a WP_Query object and enter the search query in the $object->query_vars[’s’] variable.

  123. Poli

    $query_string comes from
    function BuildSearchString($query_string=””) using global $wpdb

    The template for the directory isn’t structured like a standard theme template and $query_string is used throughout the directory to call the content.

    The solution may be to separate the search from the rest of the queries for content, in which case I could use Relevanssi. But that, obviously, is not your problem.


  124. Mikko Saari

    What’s in the $query_string variable? Is it a WP_Query object? If it isn’t, the search won’t produce any results.

    Alok, yes, if that’s what your register functions say, then yes.

  125. Poli

    Thank you for your reply. Sorry, I realised that the problem was badly described.

    I also think that the problem has to do with the template but I want Relevanssi to work. Re the hack, I just do anything. For example, replacing the original search parameters with:
    $posts = relevanssi_do_query($wp_query);
    Even works with just $wp_query;

  126. Mikko Saari

    Sorry, but I don’t quite understand what’s the problem… So you don’t get any results at all, is that it? If so, then yes, the problem is probably in your search results template. What is the hack that makes Relevanssi work while screwing the rest of your site?

  127. Poli

    Hello Mikko,

    I have been testing Relevanssi in a site and I must say it does a great job when I make it work. But I can only do that with a big hack which renders the rest of the site useless. So, it’s just to get the feel of the plugin.
    The site is a Directory (using a Premium Press template) and custom fields are very important for search results. That’s one of the the reasons I would like to make Relevanssi work for me. Anyway, the scenery is that without the hack the log shows hits but they aren’t shown in the results page. I know that indicates that the problem might be with the way the template renders the results but I thought that perhaps you may know of a way to get round it.

    The search parameters that the template uses are
    $posts = query_posts($query_string);

    I have been trying to make that work with Relevanssi to no effect. I would really appreciate it if you could give a hand on this.


  128. Alok Sharma

    ”That requires adjusting the source code. Line 1122 in the latest version.”

    How about having this as a option that what to display before and after the custom excerpt?

  129. Alok Sharma

    So in my case, I would simply enter story in custom post type to index and story category in custom taxonomies to index, correct?

  130. Mikko Saari

    That requires adjusting the source code. Line 1122 in the latest version.

  131. Alok Sharma

    How do I prevent the three dots … from appearing at the beginning when using custom excerpts.

  132. Alok Sharma

    I was wondering that what values we add in the custom post types to index & custom taxonomies to index input fields.

    For e.g. I have created a custom post type
    Singular name – Story
    Plural name – Stories
    Slug – stories

    and custom taxonomies called
    Singular name – Story Category
    Plural name – Story Categories
    Slug – story-cat

    I am confused as to what values I enter in the above fields so that Relevanssi can index them.

  133. rivermaya

    I love this plugin a lot, Im using it for all my blogs
    but I just wondering why sometimes there’s an error : Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 45 bytes) in /home/myblogname/public_html/wp-includes/wp-db.php on line 893)
    even I use the same plugins and themes, is total of posts influenced, because as far I seen only happened when the blog had huge posts


  134. Mikko Saari

    Thanks! Your problem is not an issue with Relevanssi, but with your search results template. Feel free to add links to wherever you want on your search template.

    Relevanssi doesn’t do anything that relates to search templates, it only provides the posts for the template to display.

    The disappearing third column isn’t a Relevanssi problem, either, but something wrong in your templates, most likely. Checking the code with a HTML validator may show some faulty code somewhere that makes the column disappear.

  135. Nikos

    Hello Mikko,

    Thank you for this great plugin! I believe that it’s the best for its kind to all the wordpress blogs!
    I have a question by the way. When it shows the results, there is no link to back or at least to the homepage. Is it normal that way? Can I please fix it somehow? I think it’s not so difficult to insert a link.
    Lastly, in my site, when someone is searching, my third column (right) is disappearing..!? Is there a fix for this as well?

    Thank you again Mikko and I wish you will have a wonderful year !!!!

  136. Mikko Saari

    I thought I’d killed that one for good, but here it comes again. Download 2.5.3, which fixes it, this time permanently, I’d wish.

  137. Justin Klein

    Again, when I update to 2.5.2:

    Warning: count() expects at least 1 parameter, 0 given in /home/…/wordpress/wp-content/plugins/relevanssi/relevanssi.php on line 1192

  138. Alok Sharma

    Thanks, I believe that feature will certainly help lot of people who have build niche portals and want to offer their users with advanced level of results filtering.

  139. Mikko Saari

    Upgrade to the latest version of Relevanssi. This was something that was broken in the early downloads of 2.5.1, but is fixed now.

  140. Heino

    Hi Mikko,

    Great plugin, however, I get this error, when setting the Custom excerpts/snippets to 3 words:

    Warning: count() expects at least 1 parameter, 0 given in /customers/ on line 1192 Warning: count() expects at least 1 parameter, 0 given in /customers/ on line 1192 Warning: count() expects at least 1 parameter, 0 given in /customers/ on line 1192

    In fact, it’s the same error, no matter how many word it’s set to include in the snippet?
    I’m using WP 3.0.3.

    Thanks, and Happy New Year 🙂

  141. Mikko Saari

    Yes, you can pass the parameters that way, but it won’t help you, because Relevanssi can’t do what you want. Not yet — I might add the functionality in a later version, because it’s a pretty good feature to have.

    But it would work like this:

    $your_query_object->query_vars[’custom_key’] = ’key’;
    $your_query_object->query_vars[’custom_value’] = ’value’;

    Like that — but like I said, that won’t do anything, yet.

  142. Alok Sharma

    In the FAQ, you stated – ”You can now access the query engine directly. There’s a new function relevanssi_do_query(), which can be used to do search queries just about anywhere. The function takes a WP_Query object as a parameter, so you need to store all the search parameters in the object (for example, put the search terms in $your_query_object->query_vars[’s’]). Then just pass the WP_Query object to Relevanssi with relevanssi_do_query($your_wp_query_object);.

    Relevanssi will process the query and insert the found posts as $your_query_object->posts. The query object is passed as reference and modified directly, so there’s no return value. The posts array will contain all results that are found.”

    I will very much appreciate if you can help out here. I just need to know that how I can construct the query array and then pass it your plugin. Even if you give me one small example like how to search in custom field for any value, I will then manage the rest.

  143. Mikko Saari

    I installed Thumbnail for Excerpts to my test blog and it works correctly. I’m not using relevanssi_the_excerpt() though, but the regular the_excerpt(). If I use the Relevanssi excerpt function, the thumbnails disappear. So, try using the_excerpt().

  144. Jürgen Baums

    I followed your instruction to use the function `relevanssi_the_excerpt()`, but still have a problem when using the plugin ”Thumbnail for Excerpts”: only headlines of posts in serarchresults appear.


    Rennen um Vitamine: Gemüse rasch und schonend verarbeiten
    18. Juni 2009, 11:44 Uhr

    Kraftpaket Tiefkühlerbse: wertvolle Inhaltsstoffe sind oftmals unbekannt
    28. August 2009, 10:38 Uhr

    Verbraucherumfrage: Tiefkühlerbsen erntefrischer als aus der Dose
    25. Juli 2009, 9:18 Uhr

    Any idea? Thanks a lot.

  145. Mikko Saari

    In my experience WordPress will pass a very limited range of parameters through the search form. If Relevanssi is called directly through the URL, it’s possible to use more parameters.

  146. Alok Sharma

    I believe that its possible to pass parameters to relevanssi but I don’t know how to construct the array or structure. Will very much appreciate if you can help.

  147. Mikko Saari

    ABCDiamond: I should update the documentation, the compatibility problems with the Google MapPress plugin are known. You can either not expand shortcodes or disable the Mappress plugin while you index. If you don’t use other shortcodes, disabling shortcodes in indexing is the easier option.

    Hard to say what causes the log hiccup.

    Alok: Nope, not possible. WordPress won’t pass those parameters to the search.

  148. Alok Sharma

    Thanks Mikko, I will try that.

    Just need to know that is it possible to search custom fields? I tried constructing the url like ?s=&meta_key=&meta_value= but that doesn’t seems to work.

  149. ABCDiamond

    I just installed this and got this error when indexing:

    Fatal error: Call to undefined method stdClass::display() in /public_html/brisbanebayside/wp-content/plugins/mappress-google-maps-for-wordpress/mappress.php on line 289

    I tried again, but unticked ”Expand shortcodes in post content” and it seems to work OK this time.

    I tested one search,and then checked the ”User Searches” and it said 493 hits for that one search.

  150. Mikko Saari

    Alok, you can check for fuzzy search by searching a part of a word that doesn’t exist as itself in the index. If fuzzy search is not active, you won’t get a hit. For example, add a made-up word in some entry (say ”hepsankeikka”), then search for part of it (”hepsankeik”, for example).

    Sven, that’s a long time and it definitely should be faster, but I can’t really say what’s causing it.

  151. Sven Burkert

    Hello again,
    to my problem with performance: a search for a short, common word lasts about 17 seconds. In wp admin I get a timeout, but in geshi module of wp-syntax. Without relevanssi, a search lasts 3 seconds. A search for a rare, long word lasts 7 seconds (both in frontend and wp admin). You can try it on, if you want.

  152. Alok Sharma

    Yes, I checked it again. I am using the following settings:

    Default operator for the search? AND
    When to use fuzzy matching? Don’t use fuzzy search

    Can you give me some examples on how to check if fuzzy hits are being returned. May be I am getting confused with the OR operator taking effect when AND operator does not finds any results.

  153. Mikko Saari

    Sorry, nope — when I test this, I don’t get any fuzzy results if I disable the fuzzy searching. You’re sure you don’t have the option turned on to use fuzzy searching when regular search gets no hits?

  154. Mikko Saari

    The logic should be solid. No fuzzy searches unless fuzzy searching is enabled. Unless PHP is interpreting ’if (count($matches) < 1 && "sometimes" == $fuzzy)' wrong… I'll have to investigate.

  155. Alok Sharma

    Hi Mikko,

    Yes, I double checked and I am getting fuzzy hits. In other words, if I type some long text for e.g. the title of some post and no matches are found, then I get fuzzy hits even though I turned it off.

  156. Mikko Saari

    Alok: Highlighting will highlight fuzzy matches. Are you sure you’re getting fuzzy hits, or is it just the highlighting?

    Giving users the choice of operators might be possible, though a bit tricky… The problem is with WordPress, because WordPress will only pass certain parameters (category, taxonomy, post type, so on) to the search. So, adding a input field to the search form is not possible. I suppose it could be done in the search field itself, but I’m not very keen on parsing search queries like ”cats AND dogs OR bears”, as that would require supporting parentheses to determine the order and so on, and the fact is most folks won’t use them.

    AND makes sense in what’s likely over 90% of cases.

    Sven: I’ve had occasional performance issues (slow searches), but nothing like timeouts. I haven’t had complaints about it either. Does it make any difference if you search a short, common word or a longer, rare word? Any information you can provide is most welcome.

  157. Sven Burkert

    thank you for this advanced search plugin, it delivers the search results I want.
    But I have a problem no one else seems to have: The performance is very poor, both in admin surface and in frontend (when logged in). I have about 300 articles, but only 14 are public. In the admin search, I get a timeout after 45 seconds.
    Should I do some debugging and provide you more information or do you already know what the problem is?

  158. Alok Sharma


    I believe there is a problem with fuzzy matching. I set it to ’Don’t use fuzzy search’ but it still shows the fuzzy results. I also tried building the index again but no good.

    Also, I was wondering if it was possible to offer a option such that the visitors can choose for themselves that which operator to use for search, i.e. AND or OR. Just like we pass the additional parameters like cat=.



  159. Mikko Saari

    Some people get this error, I don’t know why. Currently the best solution is to downgrade to 2.4.1. As soon as I have time, I’ll try and see what causes this.

  160. Davi de Assis

    When I search for some term the results page show these error:

    Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/guial340/public_html/guialaxia-franca/wp-content/plugins/relevanssi/relevanssi.php on line 734

    That line and area:

    if ($post_type) {
    $post_type = mysql_real_escape_string($post_type);
    $post_types = explode(’,’, $post_type);
    $pt_array = array();
    foreach ($post_types as $pt) {
    $pt = ”’” . trim($pt) . ”’”;
    array_push($pt_array, $pt);
    $post_type = implode(”,”, $pt_array);

    What I need to do?!

  161. stephen

    When saving a custom post type that doesn’t have excerpt support …

    Warning: Cannot modify header information – headers already sent by (output started at /Applications/MAMP/htdocs/vm/wp-content/plugins/relevanssi/relevanssi.php:1670) in /Applications/MAMP/htdocs/vm/wp-includes/pluggable.php on line 890

    To get rid of the warning, I modified line 1669 of relevanssi.php to …
    if (isset($post->post_excerpt) && ”on” == get_option(”relevanssi_index_excerpt”)) {

    Not sure if this limits relevanssi’s functionality, but it gets rid of the warning.

  162. Mikko Saari

    1. Even fuzzy search can’t match to stopwords, because stopwords don’t exist in the index. They are highlighted, though, the highlighting logic doesn’t care about stopwords.

    2. This is the second time I’ve heard about this kind of leaking. I’m guessing it’s a browser or server issue and has to do with how the HTTP referer is passed. So far I haven’t been able to reproduce or study this problem. I would appreciate having the results of ”var_dump($_SERVER);” from such a case.

  163. billseymour

    Mikko- Great plugin. Thanks for the good work.

    Two thoughts:
    1.Fuzzy logic: I see that when fuzzy logic is ”off”, stopwords such as ”a” will not show as results (as expected). When fuzzy logic is on (even conditionally, ”when straight search gets no hits”), stopwords such as ”a” appear as results, both on their own (”A”) and as part of a larger word ”art”).

    I suggest that Relevanssi offer an option where:
    fuzzy logic is only applied AFTER checking to see if a word is a Stopword.

    In this way, fuzzy logic could still be ”on”, and yet a stopword such as ”a” would NOT generate results, because it would the fail the ”stopword test”. As it stands now, I have fuzzy logic ”off”, but then I miss the ability to have someone who enters ”quote” also get results for ”quotes”, etc.

    2. Result highlighting: I believe that, if two searches are made back-to-back, that Relevanssi will still show the highlight from the first search if the term appears as part of the second search results.

    Example: I have a title (w/ Relevanssi looking at titles) ”Unusual Quirky”
    First search for ”Unusual”, produces the title with term ”Unusual” highlighted.

    Second search is for ”Quirky”. My result produces the title, but BOTH ”Unusual” and ”Quirky” are highlighted.

    This is NOT a problem with mechanism the actual second search. It is more that the highlighting from the first search is somehow ”remembered”. If a third search is performed, only the second search highlighting is ”remembered”, and so on.

    Just some feedback. Overall I am very happy working with the plugin. Thanks again. –Bill

  164. Mikko Saari

    Yes, you can enable them without problems, because I’ve so far found the problems happen in full index, which you don’t have to do anymore (hopefully).

  165. Aaron

    Thanks Mikko,

    Yes, I have PHPurchase and Search by Category plugins that both have short codes. I disabled them and it indexed properly. Can I now initialize them without any problem or will the site not index again because of these short codes?

  166. Mikko Saari

    Well, if you can index five items, it sounds like there’s a problem with the sixth one. In that case I’d guess it’s a plugin problem. Are you using some plugin that has shortcodes? If so, I’d wager a guess that you’d find a such shortcode in the sixth item (Relevanssi usually indexes items in ascending order of post ID, so you can fairly easily check which is the problematic entry), making it fail.

    So, try disabling your plugins and perhaps the indexing will work.

  167. Aaron

    There are 5 items in the index. I clicked continue indexing and it brings it back to the blank screen. It doesn’t index anything further.

    What kind of compatibility issues would there be? Would my existing plugins be causing problems or could it be something else? I also don’t know how to check the server error logs.

    I really need something like this plugin that uses relevancy.


  168. Mikko Saari

    Aaron: That’s either compatibility issues (check server error logs for possible error messages) or a timeout, in which case you need to click ”Continue indexing” until the indexing is done. If you reload the Relevanssi settings page, does the state of the index show any documents in the index?

    Toru: Relevanssi has multi-byte support (UTF-8 Finnish is a multi-byte language), so technically it should work, but whether it gives sensible results depends on how well Japanese conforms to the essentially English notions on how search engines are built.

  169. Toru

    Hiya, just stumbled across your plugin. Great 🙂
    I will give it a go first on my local XAMPP setup, when I get home. I run a WordPress blog in Japanese, so its interesting to see how it will come out in multi-byte language.

  170. Aaron

    I am having a problem indexing the site. I get the warning on the top of the plugin screen: ”Relevanssi needs attention: Remember to build the index (you can do it at the settings page), otherwise searching won’t work.” Even though I go through the steps and save and index it brings up a blank screen with the Relevanssi Search Options header. I then go anywhere and still get the same error message.

    Can you tell me why this may be happening and how to fix it?


  171. Will Lau

    I’ve rolled back to 2.4.1 and the search works again.

    Good luck on the bug hunt! Thanks for all of your work on this plugin, it is most appreciated.

  172. Mikko Saari

    You’re actually the second person to report it. There was a thread at the forums. Unfortunately, I have no solution for this problem and can’t even reproduce it. Any ideas on the circumstances causing it would be most welcome.

  173. Will Lau

    This is weird… Running WP 3.0.3 and Relevanssi 2.5.1

    Older versions of this plugin was fine but now I’m getting…

    Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in relevanssi.php on line 734

    Any ideas? No one else has reported this.

  174. Mikko Saari

    Make sure fuzzy search is turned off.

    Highlighting doesn’t care about stopwords, it’ll highlight every case where a search term is found in the beginning or the end of the word. If you want the plugin only to highlight whole words, you can edit the highlighting regexp a bit. It’s currently ”\b$term|$term\b” and you can make it ”\b$term\b”, that way it’ll only highlight whole matches.

  175. Richard Cantwell

    Would someone be able to tell me how to stop this plug-in from highlighting or even searching for tparts of words in a search?

    Currently i’ hightlight search terms in the results page but it highlights the likes of ’a’ – its like the stopwords isn’t working?

  176. Mikko Saari

    Yes, I just prefer to leave details like that to the theme to sort out.

  177. Me

    You can add a Read More type link by editing the relevanssi.php file at line 1127:

    Change this:
    $excerpt = $excerpt . ”…”;
    To This:
    $contread= ’<a href=”’. get_permalink($post->ID) . ’”>’ . ’ read more’ . ’</a>’;
    $excerpt = $excerpt . ”…” . $contread;

    Slightly more useful than the original.

  178. Mikko Saari

    Ah, of course – it attaches to the_title filter. Hmm, I’ll have to see how that works, because it might not be easy to figure out where the filter call comes.

  179. Joe

    First off, nice to see this is active 🙂 Great plugin, and I’ve had very few problems with it so far.

    The only one I’ve come across is with the option ”Highlight query terms in result titles too” turned on, it puts a link into the title= attribute of results:
    {a href=”url” rel=”bookmark” title=”Permanent Link to {span class=’searchHighlight’}Test{/span}ing”}
    {span class=’searchHighlight’}Test{/span}ing

    It displays the code as a string in the tooltip when you hover the permalink, and it also breaks validation, fwiw 😛

  180. Mikko Saari

    First – you can deactivate the offending plugin, index and activate again, and it should work just fine, Relevanssi just won’t index the contents of the short code. It might or might not give you problems when publishing entries with internal link short codes.

    I can’t say what’s wrong with the plugin – perhaps you should let the creators of that plugin know about the problem, maybe they can solve it. In my opinion it’s their problem, as most shortcodes work just fine with Relevanssi, and Relevanssi doesn’t really do anything non-standard with the shortcodes.

  181. Agnes

    Sorry, I forgot to paste the error:
    Fatal error: Uncaught exception ’Exception’ with message ’Incorrect shortcode for RB Internal Links’ in D:\Documents\Websites\\wp-content\plugins\rb-internal-links\rb-internal-links.php:90 Stack trace: #0 [internal function]: Rb_Internal_Links::shortcode(Array, ’Read More’, ’intlink’) #1 D:\Documents\Websites\\wp-includes\shortcodes.php(206): call_user_func(Array, Array, ’Read More’, ’intlink’) #2 [internal function]: do_shortcode_tag(Array) #3 D:\Documents\Websites\\wp-includes\shortcodes.php(151): preg_replace_callback(’/(.?)\[(wp_capt…’, ’do_shortcode_ta…’, ’As a follow up …’) #4 D:\Documents\Websites\\wp-content\plugins\relevanssi\relevanssi.php(1677): do_shortcode(’As a follow up …’) #5 D:\Documents\Websites\\wp-content\plugins\relevanssi\relevanssi.php(1523): relevanssi_index_doc(Object(stdClass), false, Array) #6 D:\Documents\Websites\\wp-content\plugins\relevanssi\ in D:\Documents\Websites\\wp-content\plugins\rb-internal-links\rb-internal-links.php on line 90

  182. Agnes

    Problem with RB internal links?

    Before testing other plugins I chose Relevanssi and on installation seems really what I need.
    The only problem is: when I hit ”build the index” I get an error related with RB internal links plugin, that uses shortcodes for links (like [intlink id=”228″ type=”page” anchor=”child-policy”]child policy[/intlink].
    Whether I check orn not ”Expand shortcodes in post content:” option in Relevanssi settings, I get that errror. Only desactivating RB internal links plugin enables me to build the index. But then I need to activate it again – and I believe relevanssi indexing can no more work…
    So… is there a way out?
    Thanks a lot

  183. Mikko Saari

    Ah, hell. I ntoiced the problem crept to the source code, thanks to slightly over-enthusiastic diffing, but I thought I’d fixed it. Turns out I didn’t fix it enough.

    I just committed a fixed version of the file, once that gets to the package, re-download 2.5.1 and it’ll work. I’m not sure this warrants a new release.

    Stupid mistake, and I’ll promise it’s the last time this happens.

  184. Justin Klein

    Hey Mikko,
    2.5.1 is doing this again:

    count() expects at least 1 parameter, 0 given in /home//wordpress/wp-content/plugins/relevanssi/relevanssi.php on line 1193

  185. Chris

    Mikko: I’d like to be able to set boost values per custom post type, because on my site I have some post types I consider more important than other post types. For example: ”Games” should rank higher than ”Previews”. Thank you for your work!

  186. Mikko Saari

    Chris: What exactly you want? Boost per custom post type, or just boost for all custom post types?

    Tom: Does Mappress use shortcodes? I’ve had similar problems with Flowplayer, and I’ve solved them by deactivating the plugin while I do the indexing and then re-activating it. I’d say it’s not my problem in any case, can’t really do anything about it.

  187. Tom Husband

    Hi Mikko,

    I get, ”Relevanssi needs attention: Remember to build the index (you can do it at the settings page), otherwise searching won’t work.”, on all pages of the dashboard. When I re-build the index I get, ”Fatal error: Call to undefined method stdClass::display() in /home/thusband/public_html/ on line 289”.

    Is there a way to not index the Mappress plugin or is this something I need to talk to Mappress about?

    Great plugin by the way. Despite the error message the search works very well.
    WP 3.0.2
    Relevanssi 2.5

  188. Chris

    This is a great plugin! I am only missing one thing: a ”boost” option for custom post types. 🙂

  189. Mikko Saari

    Sorry, this doesn’t happen with any of my sites, so it might be a problem with some other plugins you have interfering with Relevanssi. I’ve had problems indexing when Flowplayer plugin is enabled, for example.

  190. Chris

    I’m getting the following error message when I index. It looks like it does index but still has the message that I need to index.

    Warning: Cannot modify header information – headers already sent by (output started at ~~/wp-admin/admin-header.php:19) in ~~/wp-includes/pluggable.php on line 890

    (I omitted the full URL in the message above)

  191. Mikko Saari

    Try again, the plugin repository seems to do that every now and then. It’s the, and I’ve installed it successfully couple of times now.

  192. Mikko Saari

    Oops! I don’t understand how that went past my checks — I even checked with all error notices enabled — but it’s fixed now. Since you noticed it soon enough, I didn’t do a new version, but fixed 2.5, so if somebody else has this problem, re-download 2.5 and that’ll fix it.

  193. Justin Klein

    Hey Mikko,

    Just updated to 2.5, and I’m now getting the following warning spit out all over the search result pages:

    Warning: count() expects at least 1 parameter, 0 given in //wp-content/plugins/relevanssi/relevanssi.php on line 1191

  194. Mikko Saari

    Thank you! Always nice to hear someone enjoys it. Gorgeous photography on your site, by the way.

  195. Mikko Saari

    Yeah, that sort of thing happens with all kinds of plugins and hacks that bypass the changes Relevanssi needs.

    For the query_posts thing, I can offer a more flexible way to use Relevanssi in the next version: you can create a WP_Query object, enter search parameters in it and then pass that to Relevanssi. That’ll help in some cases.

    Re: custom fields — you’ve discovered some faulty programming logic in the plugin. That’s not how it should work, and I’ll fix it in the next release. Thanks for spotting the error!

  196. adam

    There is nothing wrong with wordpress pagination it was the pagenavi plugins, and one of my own design that were not working. I think it is because these particular pagenavi’s were grabbing the total count from the DB not from the query. I fixed it simply by getting the total like this instead:$post_total = $wp_query->found_posts;

    The weirdness with the query_posts may be theme related but I have it under control.

    I just noticed on my install that the custom fields selected for indexing don’t do so on new post submittal, but the body does. I need to re-index periodically so the search picks up the custom fields. If you have any thoughts on that let me know. Thanks for all.

  197. Scott

    Great plugin, definitely improves the WordPress search. I have a multisite installation though and what I am finding is that the plugin only works on the primary site. I’ve tried network activate and I’ve tried activating it on each site separately and it still only works on the primary site. What happens when it is activated on the other sites of the multisite is that no matter what you search for you get no results even when searching for something you know is there. I’ve noticed too that when I try to index on the other sites, it says indexing complete but then doesn’t list any documents in the index.

  198. Mikko Saari

    What’s wrong with the regular WordPress pagination? That works with Relevanssi, no problems.

    If you put a query_posts before the loop, Relevanssi will attach itself to it and forget everything about the other loop. Relevanssi takes the first loop on the page and uses that, because it can’t know which one of the loops is the actual search results loop.

  199. adam

    Great plugin!
    Any thoughts on paginating results, I used couple plugins and neither worked, they were still using the regular query/results. I noticed if i put a query_posts($query_string,’&cat=3′); before the loop it negates the plugins functionality and the posts are displayed in the default order (by date).

  200. Mikko Saari

    It’s completely automatic. Just do the initial indexing manually, then everything else comes automatically.

  201. gil

    does your plugin relevanssi reindex automatically? or does it have to be reindexed every single time you make a change to a post?


  202. Mikko Saari

    Thanks for your kind words. I do get the occasional PayPal donation, but fortunately I do have a day job to pay the bills =)

    I think what you want can be done. I think I can add a new filter you can use, so you can pass pretty much anything you want to the Relevanssi highlighting engine. I’ll have to see how that works when I have some spare time. It would help me to see what you’re trying to do, so if you can, please send me some code to mikko @ — I’m interested in the search result loop.

  203. DesignBuildTest

    Hi Mikko, thank you for creating such an incredibly useful plugin. I try to avoid using Google Custom Search on my WP sites and have always preferred plugins that extend and customise WordPress native search. Relevanssi is an elegant solution to many WP search problems and I hope donations to your PayPal account reflect the hundreds of hours it must have taken you to build such a fantastic tool.

    My PHP knowledge is very limited, but I was wondering if it would be possible to extend Relevanssi so it indexes and highlights content beyond what is found in the_excerpt() and the_title()? I have a simple search loop structure that contains content from the_title(), the_excerpt() and the results of a custom field. I am storing address information (street name, building number etc) in my custom field and it would be great if this information was able to be manipulated by Relevanssi. I could write a simple php function to show address details associated with each post and wondered if I could then force Relevanssi to target the contents of this new function and programmatically insert <strong> tags much like I assume you do with with content from the_title() and the_excerpt() functions?

    A final thought, I note in the comments above there are currently no plans to Multi-Site enable Relevanssi. I wonder if one of the guys at would be willing to tackle this task given how important search is to user experience/expectations?

    I hope all is well in Finland, all the best from the Wellington New Zealand and thank you once again for such a wonderful plugin.

  204. Mikko Saari

    I’m sorry, but I can’t help you further with this – I simply have no idea why the search doesn’t work. Does the highlighting of the search results come from Relevanssi, ie. is Relevanssi processing the search results at all?

    Another thing: does your theme have extra WordPress loops on the search page? That would mess up Relevanssi, because Relevanssi doesn’t know which are the search results and will just tackle the first loop on the page. That would explain why the search results don’t change at all.

    Relevanssi doesn’t need the default search box. You can definitely use the pretty search box you now have with Relevanssi, as long as it passes the search terms in the s parameter, like it does.

  205. Andrew

    The search plugin I’m using is called RokAjaxSearch which basically makes that search box more pretty, however, it also does have options (which you can see at The thing is that even after disabling it and using the normal search box, the results are the same. The problem is that the search results are being sorted by date. World of tanks and torchlight work because they are recent posts.

    I tried setting the rokajaxsearch thing order by ’title’ but that doesn’t help. Rokajaxsearch is part of my theme and I have a feeling that if I go ask them for help they will point me to you :). Even if somehow relevanssi manages to work without rokajaxseach, the default search box looks ugly as hell on my theme.

  206. Mikko Saari

    Some searches work, some don’t – ’dragon age’ doesn’t, ’world of tanks’ or ’torchlight’ does.

    You’re using some other search plugin, the result page has extra parameters like ”&limit=10&ordering=date&task=search”. It’s possible this other plugin is causing a conflict with Relevanssi. Try disabling all other search-related plugins and see if that helps.

  207. Andrew

    Use the search box on the side bar.

    For example, I want to take a look at my Dragon Age review. So I type in ’Dragon Age’. The results however, are completely different and it appears that the search is being sorted by date, not by relevancy as the result I’m looking for comes last.

  208. Mikko Saari

    Are you talking about Wavegaming? Looking at the search results you’re running Relevanssi just fine, at least there’s highlighting that standard search won’t do.

  209. Andrew

    I can’t for the love of me get the plugin to work. I mean the setup and everything is fine, but it’s simply as if the plugin is not even there. I still get the same search results with the default search feature and it’s horrible :(.

    Index is built, default search operator is AND, I even set the title boost to 60, but no juice.

    Any thoughts? :/

  210. Mikko Saari

    Not right now, but it’s on the to-do list. WPML is a popular plugin and as a bonus I’m also using it, so I have a good environment to test in. So, expect WPML support in a future release.

  211. AnyDog

    Hi Mikko . Great plugin !
    I really had a problem with default wp search and with some other plugins, but yours really does the work.
    I have just one question – i’m using Relevanssi on multilanguage site (4 languages with WPML plugin) and I was wondering if it’s possible to show results only in current language, not all languages that has matching reslults ?

  212. Tom Husband

    Thanks again, Mikko. I’ll send you the error report separately. I uninstalled and reinstalled Relevanssi and it seems to work except I can’t get rid of the prompt, ”Relevanssi needs attention: Remember to build the index (you can do it at the settings page), otherwise searching won’t work.” that appears at the top. I ran the index and it appears to complete but the settings page comes back blank. When I refresh it’s back but I have that message.

  213. Mikko Saari

    Enable the error reporting, do a search and send me whatever gets printed on screen, perhaps I can help you there. My email is mikko at

  214. Tom Husband

    Thanks, Mikko, but I’m afraid I’m a bit lost on this. I uncommented those lines and got a lot of text when I did a search. I have no idea what to look for in it or even what to do. I’ll deactivate for now.


  215. Mikko Saari

    Are you sure have all the necessary PHP modules, particularly the mbstring module? Relevanssi should complain about it in the admin panel if that’s the case. In any case 2.4 works and if there’s a problem, then it’s something local on your system. You could try uncommenting the following lines in the relevanssi.php file:

    //ini_set(”display_errors”, 1);

    So they look like:

    ini_set(”display_errors”, 1);

  216. Tom Husband

    I’m using 2.4 but when I search I get a blank page. Could it be something else that’s causing it?

    WP 3.0.1

  217. Mikko Saari

    I know, and I’ve already fixed it. I’ll release 2.4.1 shortly.

  218. Will

    Mikko, thanks so much for this wonderful plugin. It works a treat. Really small minor bug I’ve noticed in the search highlighting. Say you search for ”john” and the search highlighting will display snippet hits as ”john” not ”John” as it was actually written in the article.

  219. Mikko Saari

    Not a bad idea – just inconvenient. There’s all sorts of stuff that would be fun to index, but the restriction that everything Relevanssi handles should basically be a post (or something that can be fetched with get_post()) limits things a lot.

  220. JF Lussier

    Hi Mikko,

    thanks for your explanation. I suspected it would be complicated. My double install does not use MU. I tried using MU before chosing a double-install approach but for some reason (I don’t remember which) it did not work the way I wanted.

    I see how searching widgets can generate repetitive results. I hadn’t thought about how to present the results for just the widget itself to be made available. I guess it was a bad idea.

  221. Mikko Saari

    That would require huge amounts of hacking. I suppose it’s possible and if you really want it, I’ll do it if you pay me enough, but it would take lots of changes in the structure of things. That is if you’re talking about joining two completely different installations of WordPress.

    If you mean the multisite WordPress that used to be WPMU, making Relevanssi co-operate with that is certainly on the list of things to do, but as it is something that is a major operation and something I personally don’t need, it’s so far down the priority that frankly it’s unlikely to happen unless somebody else does it.

    Searching in widget texts… Sure, but if you’re talking about sidebar widgets, the text isn’t really connected to any single post or page. If a sidebar widget is on every post, searching for the text it contains should produce as a hit every post, which makes zero sense. Or do you mean something else?

  222. JF Lussier


    my Web site is composed of two WordPress installs : one in english and on in french. Do you think relevanssi could ever be used to search through two separate databases? Would that be complicated?

    It would be nice if someone searching for an english word on the french website could get results from any page – english or french.

    People use multi-install sites for other purposes than bilinguism, so it wouldn’t only be useful for that specific purpose.

    Also, I have an improvement suggestion : search in widget texts.

    Thanks for all your work!

  223. 2046

    the problem is that if you use slug and work with for example xlanguage plugin then the term, title or text can be like:
    ”Prague|Praha” (this logic divides the laguages, it can be even more like lang1|lang2|lang3|…)
    but the slug is same or clean like Prague for certain reasons(clean url, geo ip 🙂 etc..)

    In my case, performing the search for ”praha” gives me about 2pages(20 posts) , but in the case of Prague it is 13 pages(130 posts), although it is a ”same thing” :O

    I know this is proprietary problem, especially together with xlanguage, but it’s worth to consider.

    tax, custom f. highlighting:
    I’m sure it’s not easy. I try to do it by my self now, it works ”well”, but the separate words.

    There are many things that works partially in your plugin… like when i look for word ”cepan” it gives me the right result with all occurrences of the ”čepan” (notice the first letter č) which is grate. But the highlight logic won’t highlight it. Seams you use 2 different logics. One for search and one for highlight.
    you can try it here (I’m working on it so it might trigger error from time to time)

    I’m not saying you did bad work, not at all. I’m happy with the plugin you made, but i think it can be improved.

    If these suggestion don’t bother you, we can discuss it via email it think there are more things then this. Plus, as I said, if you will help us we can pay for the work, and you can keep the result as a part of the free plugin. I’ll send you donation anyway, but this participation might be good for both sides and all the users.
    thanks 2046

  224. Mikko Saari

    Using slugs is useful, because the taxonomy terms must often pass through in URLs and slugs will remain intact.

    Highlighting custom fields and taxonomy terms… that’s a bit tricky, unless there’s a suitable WordPress hook. I can also take a look at creating a separate function to use in templates.

  225. 2046

    I’m sorry man for another post. I just figure it out that in the case of taxonomy terms, it looks through slug not names..which is bug, from my point of view.
    thx 2046

  226. 2046

    .. sorry, but the bug with img title is not your bug. I found out that I run my own img function that ads the_title into img title, and because your plugin actually changes(look through) the_title tag it obviously change my img title ;(
    Ok, I’ll find a way around.

    thanks 2046

  227. 2046

    thank you for the awesome plugin.
    I found one bug and have one suggestion.

    when the highlight is on, it looks through the whole page content and also into image titles.
    When it finds the term/s in img title it puts the highlight code into it and so the html is not valid and the page is rendered wrong.

    Once there is a grate possibility look through meta and taxonomy, it’ll be also awesome to have highlight for these things in template. Or maybe a small function we might use on any temlate tag where it will put the highlight logic. Your Highlight logic is super and highly tuned so it highlight also words that are not close to each other, it gives us back the right cases and works well with utf-8 internationalization. So if we can use the logic separately it would be grate.

    if you have a time to focus on these things and want a support($) let me know, I’ll find something for you.

    thanks a lot 2046

  228. Mikko Saari

    As far as I can tell, Relevanssi and Hyphenator won’t interact. Hyphenator works in the client, so it doesn’t affect Relevanssi in any way.

    If entries contain soft hyphens, Relevanssi replaces them with spaces, which seems wrong. I’ll fix it so the soft hyphens are completely removed when indexing.

  229. Mikko Saari

    Quick solution for the hit count question: just use < ?php echo $wp_query->found_posts; ?>.

  230. rd

    perfect! that is killing this annoying error-message. thanks by the way for your help and of course for this great plugin.

  231. nika

    im loving your plugin, thank you very much! It does such a wonderful job when searching inside custom taxonomies!

    im not good at php so i wanted to ask you this:
    ** Is there a way to get how many result relevanssi got?

    You see, i want to display ”Found 13 results for Lorem” im using this:

    $allsearch = &new WP_Query(’s=$s&posts_per_page=-1’);
    $key = wp_specialchars($s, 1);
    $count = $allsearch->post_count;

    but of course unless the search term is in the title or content it wont count it in.

    Still! Best search plugin out there

  232. Mikko Saari

    If you aren’t afraid of diving to the code, find the offending function call on line 1349 and prepend it with @. So, instead of mb_strpos(whatever) you have @mb_strpost(…). That should make it shut up.

  233. rd

    supressing would be ok as a first step. but how?

  234. Mikko Saari

    I’ve heard other reports about this as well, but I haven’t had time to take a look at it. I’ll do that as soon as I can and will fix the problem – if nothing else, I can suppress the error message.

  235. rd

    There is an error message:
    Warning: mb_strpos() [function.mb-strpos]: Offset not contained in string in relevanssi.php on line 1349
    This happens, when I activate the title highlighting. But even still appears after deactivating the title highlighting, because when I do a search and go in the details of a search result, the error message is in the same line and formatted like the title of the search result.
    No idea what went wrong. Everything else is working fine.

  236. seriocomic

    Congrats on what I have found to be the ONLY search plugin that delivers what it says and does it well! Nice work.

  237. Charles St-Pierre

    Thanks for the credits: Happy to help.

    Bug report:
    Lines 716 to 724 should return a list of post_ids, based on what is on line 795.
    So we need to change line 795 to something like lines: 777-778

    $query_restrictions .= ” AND doc IN (SELECT DISTINCT(object_id) FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ($taxonomy))”;

  238. Mikko Saari

    Version 2.3 committed — including this little gem, search term highlighting in posts and a bug fix on admin search highlighting. Enjoy.

  239. Charles St-Pierre

    Thanks for the quick response.

    I continued on my wonderful road to ”making wordpress search suck less” and figured out by myself what your saying about taxonomy filtering. ARHHH! Even worst, its not possible to search by multiple taxonomies (other than the built-in categories and tags). I came to the conclusion that my search tool would have to be limited to filtering by: 1-post-type, 1-taxonomy, 1-term. (I know we could select multiple post types, but in order to have a dropdown of taxonomies, I need to restrict to one post type).

    at line 795, add
    $query_restrictions = apply_filters(’relevanssi_where’,$query_restrictions);
    But you must document that it needs the general pattern of
    ’ AND doc IN (’ . {a list of post ids, which could be a subquery} . ’)’
    I’ve done it in my version, and it works like a charm.

    That way, you don’t need to join Relevanssi table with wp_posts. And I think that, in this case, subqueries will be faster then joins.

    It will also open the door to other insertion a custom list of post_ids, which could be preselected by multiple search parameters. It would be a wonderful asset. Looking forward to 2.3

  240. Mikko Saari

    Somebody asked me about those MySQL where hooks, and I replied that I would definitely consider adding them. I suppose the best solution would be to add a filter hook, where you could add whatever you wanted to the where clause — that would cover all sorts of hacker needs without much complexity in the user interface.

    Around line 795 the plugin would call whatever functions are hooked to, say, ’relevanssi_where’ and add their output to the $query_restrictions variable. That’d be fairly easy. I think I can do that this weekend.

    You got the basic idea right – the query is restricted with AND clauses to certain post_ids. I guess I could join the Relevanssi table with wp_posts, so the post data (for example post_date) would be available. Unless I’m missing something here, that would make at least date filtering fairly straighforward.

    The taxonomy filter is using terms, because that way it plays nice with WordPress default features. The way WordPress handles taxonomy restrictions in search is also the reason why it’s limited to one taxonomy, as WordPress will only pass one taxonomy term.

  241. Charles St-Pierre

    Hi, First, Great plugin. I’m trying to improve the search capabilities for our sites, and your plugin is a great addition.

    I’ve been looking in Relevanssi’s source code to filter the search results. I managed to add filters with multiple post types and multiple categories.

    I’m still trying to figure out how to filter by multiple custom taxonomy (looking around line 715 gave me some pointers, but would be nice to be able to give ids directly, not terms).

    What I would really like is to filter by time (specific dates and ”for the last X days”). In basic WP, you could filter ”post_where” and add ”AND post_date > 2010-08-01”. No such hook in Relevanssi. I think I’m starting to understand the basic working. You collect post_ids based on restrictions, AND THEN search in Relevanssi table, limiting the result of this collection.

    Am I right? I’d really like if you could point me in the right direction. I’d gladly give you the result of my work on your plugin.

  242. Mikko Saari

    Just adjust the WordPress setting of entries per page, that affects Relevanssi as well.

  243. Hal


    This plugin is fantastic! I’m really loving it over the default search tool. I just have one question on my mind, though: Is it possible to adjust the search results per page from the default 10? 10 fits pretty awkwardly on our site and 9 would really be ideal.

    Thanks in advance.

  244. Mikko Saari

    No weights for custom meta right now. It can be done, but I’m not sure it’s worth it. The weights you’re thinking about won’t have a dramatic difference in the results, I believe.

    Re: partials, check your setting for fuzzy search – you might have the wrong option there. If fuzzy search is always on, it should definitely match ”espress” with ”espresso”.

  245. keranm

    Sorry to bug you … but umm I seem to be having trouble getting it to hit for partials – is this expected?

    Eg a search for ”espress” will not find ”espresso”

  246. keranm

    Thanks Mikko
    Is there a way to add weights for custom meta content?
    I know I can tell the plugin to index specific meta content .. but can I weight some over others?

    Eg: I have meta content (”address_number”, ”address_street”, ”address_suburb”, ”address_city”) – could I set it up so that address_city was weighted 1.2, while address_suburb is weighted 2.4

    Loving this plugin dude 😀

  247. Mikko Saari

    Yes, it’s just a multiplier so values less than 1 lessen the value.

  248. keranm

    Question for you:
    If: ”0 means titles are ignored, 1 means no boost, more than 1 gives extra value”

    Then the default settings of 0.75 and 0.5 … do they drop a results score down (as in give negative boost)?

  249. keranm

    Super plugin … I LOVE it!!

    Would love to see it extended and growing … keep up the great work.
    I was looking to use Search_Unleashed as it has a Lucene engine in it … but I think Relevanssi gives brilliant results … esp for my little project that is …. (well more on that later)

  250. Mikko Saari

    It’s actually very simple: see ”Building the index and indexing options”. The first option is ”What to index”. Choose ”Just posts”, and no pages will be indexed. If you want to also index custom post types, you can list them in the next option – there’s probably less of them than pages to exclude.

  251. Andrew

    Hey, great plugin you’ve got there! I’ve been looking for a plugin to replace the crappy default search for like forever!

    I’ve just one question – is there any way to disable Relevanssi from displaying absolutely ALL pages from search results? Cause I have quite a lot and I don’t want to manually add all their id’s one by one.


  252. Mikko Saari

    Nope, Relevanssi lists either AND results or OR results, not both at the same time.

    But I suppose it wouldn’t hurt, if the operator used was visible.

  253. Jason


    Awesome plugin! I was wondering, however, if it’d be possible to include a divider in the search results, i.e., if I search for ”Gold Panda”, I understand that Relevanssi first lists those that match ”Gold” AND ”Panda”, and then shows results for ”Gold” OR ”Panda”. I’d love it if we could show a header above each (using our own customized CSS header) that says something along the lines of…”Results for Gold AND Panda” and then a second break that says ”Results for Gold OR Panda”. I know that it just gets confusing for some of my users to see such a breadth of results that may not hint at any similarity, save for the fact that one word in the content matches.



  254. Dietrich Koch

    Hello, after I sent a comment to your site I cannot see any comment only the number 6 comments are there. I assume you answered my question

  255. Mikko Saari

    As I said, I have no experience of using Relevanssi for admin side, but there’s nothing in the code that would prevent custom fields from working. They are indexed and admin side search doesn’t exclude them (category, taxonomy and tag restrictions are removed in admin search) in any way. I’ll have to investigate this.

  256. Dietrich Koch

    Hallo Mikko,
    relevanssi is realy nice and very useful for a project searching missing persons I am technically supporting (for honor, unfortunately). Here it is very important that it works for admin too. There is only one problem with searching for subheaders (custom field: _subheading, created by the plugin subheading). It works for frontend without problems but not for the articles in admin. Is it possible to take into account the custom fields also for admin?
    Thank you

  257. Mikko Saari

    I’ll have to admit: I’ve never ever used Relevanssi for admin searches. I’ll have to fix that, no highlighting for admin searches, that’s clear.

  258. randy

    Hey, been using the plugin for a while. I like the progress. One thing I noticed:
    I enabled the use of the plugin for searches on the admin pages. I was looking at my POSTS listing and did a search for a word. The resulting list of posts was correct, but the titles listed had ” xxxx ” tags appearing in the post titles. I guess this is the plugin’s attempt to highlight my keyword, but it really messed with my brain for a second.

    Anyway, it might be something to fix when listing posts searched in the admin pages.
    I am using WP 3.0.1, if that makes any difference.

  259. Mikko Saari

    It’s not supposed to do that, but the feature is on the to-do list, so it’s pretty much a question of when I have enough free time.

  260. JF Lussier


    revelanssi works fine except for one thing : it doesn’t highlight results on the target page or post.

    Is it supposed to do this or is it designed to only highlight results in excerpts and optionally in titles?

    It would be nice if it did.

  261. Mikko Saari

    The most common stop words – those common to all blogs – are already on the stop word list. Otherwise they would appear on the list of the most common words.

  262. Timothy Spaulding

    How do I add words to the stoplist that are not on the most common words list? I would like to exclude searches on ”for”, ”on”, ”the”, etc.

    Thanks for the great plugin.

  263. Mikko Saari

    Relevanssi has nothing to do with the amount of results listed on the search result page – that’s the work of your search result template. From the Settings and Reading, how many posts are listed on each page? That too affects the search results.

  264. Mikko Saari

    Check the timer, I want to know which part of the script takes all the time. Maybe that’ll help us to figure out what’s wrong.

  265. Li-An

    A mystery to me: I clean everything (delete the table and all) and rebuild the index. Same problem on ”Chaland” ! Will have a look at the posts to see.

  266. Mikko Saari

    You can try that, if re-indexing doesn’t help.

  267. Li-An

    I don’t know if there are other problems with other words. I noticed problem with Relevanssi (no color ) with this word (but the time and the links were good) but not only this one. So I reinstall an old version (read comment before :-)) and when testing this same word I noticed the problem. It may be a problem with the database. I suppose I have to delete everything with the plugin and reinstall it completely ?

  268. Mikko Saari

    That’s odd – searching for ”champaka” works. Has the same happened with other search terms? Is ”chaland” a common or a rare word?

    I was thinking about doing a speed test to see where the delay in that search is.

    In any case I would recommend reindexing.

  269. Li-An

    I’ve just made a try without Relevanssi activated and the WP search works fine. So I need to reindex everything ?

  270. Li-An

    I had some problem with 2.1.4 version (the color did not show) so I reinstall 2.1 version, saw it works and reinstall 2.1.4 version. It works fine … except for some words it just take a lot a lot of time to give search result. Try ”chaland” on my
    I tried to reindex the stuff but I just got the ”blank page” even with all plugins desactivated 🙁

  271. Mikko Saari

    I got the same error message on one of my blogs. I don’t know what’s the problem there, as the line is good PHP code and the plugin works on several other sites. Perhaps it’s a question of PHP version… I’ll change that code a bit, try the next version (out later today) and see if that works.

  272. Jen Chambers

    Trying to update the plugin and can’t activate it. Getting the following error.

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /export/home/ on line 546

    I deleted it and downloaded the update and got the same error.

  273. Mohib

    Always returning results is not always satisfactory also if you’re looking for specific items. Perhaps I can suggest a useful compromise, provide an additional breakdown keyword.

    Right now you have keywords %score%, %body%, etc. and if you had something line %terms%, which listed the terms that were found in the post and their counts, then one can quickly see what terms were found, and how many hits, listed in decreasing hit count. So if I searched

    gardens public Vancouver

    %terms% could return something like the following (at the end of each snippet as you currently do for other breakdown keywords):

    public:10, gardens:12, Vancouver:3
    Vancouver:7, gardens:5, public:0


    This would be quite useful so one can see quickly the ”relevance” of a hit besides your own ranking and I can quickly assess what is relevant to me. For example, the second hit above would be more interesting if I wanted to focus more on Vancouver, even though it ranked second.

    I’ve never seen this and have always thought it would be very useful to augment the mechanised ranking algorithms.

  274. Mikko Saari

    Option a) wouldn’t make any sense. It’s b), if the plugin would return ”nothing found”, it checks again with the OR operator. That way the user experience is as good as possible, because ”nothing found” is not a good result in any scenario.

  275. Mohib

    When you say ”… it’ll resort to OR if no hits are found)”, does this mean

    a) if no hits are found in a particular post it resorts to OR and researches that post, or
    b) if no results are found after all posts are searched with AND it researches all posts with OR?

    If you’re flip flopping post, by post, i.e. option (a), then the results list will be a real mishmash as posts that may have many instances of some of the words could get ranked higher than those with all the words (which should actually be ranked higher).

    if you’re doing option (b), then switching to OR sounds like a good compromise, but if you’re look for only hits with all words, i.e. AND, you don’t know none have been found because all these other hits show up from the OR searching and you have to wade through them all only to realise none of these hits have what you want, so I would provide an option to fall back to the OR option.

    Personally I wouldn’t use the fallback to OR for the above reasons.

  276. Mikko Saari

    Thanks, and thanks for the link from your site, extra visibility never hurts.

  277. ThinkTutorial

    Mikko, just wanted to pass by here and let you know that your search engine is fantastic. We started using it on and it’s doing an amazing job! Keep up the good work! 🙂

  278. Mikko Saari

    I just committed Relevanssi 2.1.3, where you can choose which operator you use (and AND is better, because it’ll resort to OR if no hits are found).

  279. Mikko Saari

    It takes couple of changes. Be patient, and I’ll get the next version out next week or so, and there it’ll be an option.

  280. jebe

    I use last version of relevanssi, 2.1.2, but I prefer use OR than AND. how to edit it? thanks

  281. Mikko Saari

    Right now it’s only AND, so the queries without all search terms don’t get listed at all. I think it makes for better search results, especially with fuzzy matching. I think I’ll make it an option in the next version, though.

  282. randy

    Thanks for all of the updates. My search keeps getting better and better thanks to your evolving plugin!

    Regarding AND vs OR, I like the strict criteria of AND, but the flexibility of OR. In the plugin description, is states you rank matching all terms higher than matches of just some terms. Does it still do that? It seems like that’s the best approach. AND matches first, followed by OR matches.

  283. Mikko Saari

    Best way to remove stopwords is to use some program to access the database (phpMyAdmin is the most popular option) and remove the necessary lines from the _relevanssi_stopwords table.

  284. Mohib

    Perhaps it would be easier if I gave you access to my blog. It’s currently not public so please e-mail me and I’ll set up a temporary account and then I can show you the results as well as the search criteria and you’ll be able to judge better and you can run some tests yourself also.

    How do I remove a stop word from the database?

    Re ”AND” by default, that’s great. I think that will go a long way to help as right now there is no way to narrow a search to hits which contain several words.

  285. Mikko Saari

    The highlighting code doesn’t know what caused the hits and making it know is not worth the trouble. Coding an elegant and fast solution for highlighting is complicated enough as it is, so I’m not going to change it right now. The highlighting scans the documents trying to find the keywords and has some rudimentary mechanisms to ensure there are as many present as possible.

    When checking search results, never mind the highlighting — just check which documents appear. Try with a search that produces few results — do you get exactly the same documents (possibly even in the same order) with fuzzy search on and off?

    The problem with phrases is that they work perfectly on my installations. As long as I can’t reproduce the error, it’s very hard to fix. There’s some evidence that removing the punctuation doesn’t work on every system — there’s your problems and somebody else has problems with + signs that don’t get transformed to spaces.

    I still haven’t done any interface for stopword management, so the only way to remove a word is to remove it directly from the database and then re-index.

    By the way, I’m going to experiment with having AND operator as default. I’m starting to feel it’s probably a good idea and would remove some of the problems you’ve had and perhaps reduce the need for special operators.

  286. Mohib

    ”The search result highlighting has nothing to do with finding hits — it will highlight partial matches even when fuzzy search is turned off.”

    This is *very* confusing. You should only highlight what triggered a hit.

    ”Are the search results otherwise identical whether fuzzy search is on or off?”

    They appear to be but it’s hard to tell with the highlighting as you do it.

    The problem with phrases is very serious for me. I hope you can fix that soon because without it I can’t find much as I use that all the time.

    9) How do I remove a word I’ve added to the stop word list so it’s no longer in there?

  287. Mikko Saari

    The fuzzy search uses *term and term* to find hits. Both are necessary when searching in languages like Finnish or German. Maybe *term is less necessary in English. I usually do have fuzzy search turned off unless no hits are found otherwise to avoid unnecessary hits, but it’s useful there.

    The search result highlighting has nothing to do with finding hits — it will highlight partial matches even when fuzzy search is turned off. Are the search results otherwise identical whether fuzzy search is on or off?

    What comes to the although issue, I don’t know — the latest version should strip all punctuation but if it doesn’t, I don’t know what’s the problem.

  288. Mohib

    Ok I’ve loaded v2.1.1 and re-indexed. Problems (1) and (2) are still there and giving same results as explained. The word ”although” is still giving the same results.

    8) I’ve turned off fuzzy search and if I search with:
    failure in our
    it’s returning hits with partial words: source, continues, etc are all partially highlighted. It wasn’t doing this in v2.1 as far as I remember because I specifically turned off fuzzy search so I knew only my words were being found as I found the fuzzy searching results too strange.

    I think the fuzzy search finding internal parts of words is not a good method. My experience is that usually only word derivatives are found, so if i search on ”our” things like ”ours” would be found but not ”yours” because all that is happening is that a lot of irrelevant words are matched and pushing irrelevant posts to the top of the list.

  289. Mikko Saari

    1) Strange… Install 2.1.1 (which should be available now) and re-index, maybe that helps. I haven’t marked the correction in the changelog, so I’m not sure when I did it. 2.1.1 should work. If it doesn’t, then there’s something strange going on.

    The stop word file has only the default stop words, the actual stop words (including the user additions) are stored in a MySQL database (_relevanssi_stopwords).

    3) I thought Google defaulted to OR, but you’re correct, it’s AND. However, there’s a difference between searching billions of web sites and contents of a single blog… In a blog environment, defaulting to AND would restrict the searches too much.

    But I’ll do the +/- operators, it’ll just take a while as it’s big change.

  290. Mohib

    1) The first time I ever loaded relevanssi was yesterday with v2.1 and have re-indexed several times. Should I re-index again or wait for v2.1.1?

    What is the name of the user stopword file? I looked there and found a file called ”stopwords” but it doesn’t contain any of the words from the top 25 list you provide which I clicked on to add them to the stopword list, although those words are no longer being found, so I’m not sure what stopword file those went into.

    3) Yes I agree google has the OR and other operators, but by default google does an ”AND” between the terms and also lets you control partial word matches with ”*”. I think it is important to have some version of ability to narrow the searches (default AND between words, or +, etc.) and hope you’re able to implement some ability to control how the search terms are used and combined to allow narrowing down the search scope.

    Glad to help and look forward to some of the improvements you’ve mentioned you’d like to do

  291. Mikko Saari

    1. Yes, that looks like something that just doesn’t work with Relevanssi. That code is not showing the true hit count for relevanssi.

    Also, you’re using a new enough version of Relevanssi, but you need to reindex the database. That ”although,” is left by a faulty version of Relevanssi, which didn’t remove punctuation correctly. If you reindex, it should disappear.

    The stop word file is ”stopwords” and located in the plugin directory.

    3) Google uses partial matching as well, if you enter two words in Google it’s equivalent to ”this OR that”. But of course in Google the database is different and you have the option to use the + operator. I’ll see what I can do about these operators. Using Boolean operators would require adding a different mode for full match searching and that won’t happen, but +/- operators sound like something I could do.

    7) Ok, that definitely sounds like Sniplets is using something else than the basic shortcode expansion code, so Relevanssi won’t catch it. I’ll have to investigate.

    Thanks, you’ve been quite constructive and helpful here!

  292. mohib

    Thanks for your reply.

    1) I’m using the Piano Black theme (with mods) from here:

    But the search.php has this code at the top to display the results (not exactly sure what it all means, although I can guess to some extent):

    <?php _e(’Search results for ’, ’piano-black’); echo ”[ ” .$s. ” ]”; ?><span id=”search-hit”> – <?php $my_query =& new WP_Query(”s=$s & showposts=-1”); echo $my_query->post_count; _e(’ hits.’, ’piano-black’); ?></span>

    It also was using rss_the_excerpt() until I changed it to the_excerpt() as per your instructions.

    Well the results I got with ”although” were as above. The one hit found was the exact word with a ”,” after it.

    Also I had added words to the stop word list, from the 25 recommended words, but they are still being found as exact matches when I use fuzzy search (but not if I turn fuzzy off). Shouldn’t all exact matches be ignored, fuzzy or no fuzzy? BTW where is the English stop word file? I can’t find it to see what’s in there.

    3) Ah that is why I’m looking for boolean because generally if you give 3 words you want hits with those 3 words and right now I’m just getting too much back. So right now there is no way to narrow a search down as you’re using any of the terms, don’t have booleans, and don’t have +/- operators. I think you need to provide the ability to use more than one term to narrow a search at a bare minimum (as that is what people are used to even in google), but ideally also have boolean and +/- operators.

    5) Great!!

    6) Yes I would just use the same settings. People have already seen them highlighted in yellow or whatever on the results page, so to change it for the post page would be more confusing. Also I’m not sure of the value of having different colours for different terms as it’s more confusing and I never remember the colours anyway.

    7) Yes if I search for ”sniplets” it ginds the ”sniplet” short code! Sniplets has lots of different types of things it can insert but I’m just using the basic, plain static ones, so there shouldn’t be any issues with dynamic content.

  293. Mikko Saari

    1) Actually, I think it’s possible the hit count may be what WordPress search would return, not what Relevanssi finds. How do you get the hit count? Let me know, so I can experiment.

    For example, with ”although”, you really should find nothing at all. It’s a stop word (assuming you’re using the English stop word list) and thus removed in the indexing. You’re finding something in the fuzzy search for some reason, but you shouldn’t get many hits in any case. WordPress search might indeed find 46 hits.

    If that’s the case, I’ll just have to come up with a way to display the amount of actual hits found.

    2) Oops, looks like I updated the plugin, but didn’t update the readme file, so plugin repository won’t let you download 2.1.1. I’ll fix that tomorrow. I’m not sure where the phrases bug was fixed, was it 2.1.1 or earlier…

    3) Relevanssi returns hits with any words. All words are not required, but the more words there are, the better score the document gets.

    5) Sure, why not – I’ll see how complicated this is.

    6) Copying the best features from your competitors is always a valid strategy and this is a really good feature, so yeah, you can expect it in some future release, depending on how difficult it is to do. I was thinking about using the same highlighting as in the search results to reduce the amount of different settings, would anybody want to use different highlightings (and that would be possible through CSS classes anyhow)?

    7) I’ll install Sniplets in my test blog and see what’s going on. I’m guessing Sniplets uses different way to expand the shortcodes. I suppose if you search for ”sniplet”, you also get results?

  294. mohib

    Thanks for your reply.

    1) What additional information would you require? Sometimes the results total says 1 found even though a dozen hits are returned — this is usually if I put two words to search. Sometimes the results says 29 and I’ve got about 100 returned.

    The count never seems to match what’s returned. I was searching for ”although” and with fuzzy searching always on I got 1 returned but 46 in the count. With fuzzy searching always off I got nothing returned and a count of 0. Without relevanssi and using the default wordpress search I got 46 in the count and 46 returned.

    2) I downloaded it yesterday from only v2.1. 2.1.1 is not available there.

    3) When I put more than one word, the results seem very inconsistent right now and I can’t seem to figure out if you’re finding documents with all terms or any terms (also see #1).

    5) Drop down boxes are usually ugly and mess up the graphic design, some special codes would be best, like google does for example with ”site:” and so forth. I think ”cat:”, ”tag:”, ”custom:=value” (rather than an exact match, just search for the value in the field) would be really great and let you focus the search better. And of course you should be able to use them all and multiple times so if I wanted to find something but search two categories, I’d use ”cat:a cat:b”. I agree most people like things simple, but as a developer myself, I’ve found that implementing the most common/likely requested 2 or 3 of the rarer features likely desired is what makes a great product become the most recommended.

    6) The highlighting would be really great. I’d don’t think the links to jump to the first occurrence is so useful and the box looks a ugly, but if you could highlight the hits, that would mean one can just scroll down quickly and see all the hits without having to use the browser to search again.

    New problem I just found:

    7) I’m using sniplets and have turned on expand short codes in relevanssi but it’s not finding words in the sniplets and instead find the sniplet name (if it matches the term I’m using).

  295. Mikko Saari

    I haven’t tested Relevanssi at all with multisite installations, but if the posts are in the same database, Relevanssi won’t make a difference between the blogs. It’s something I can look at developing in the future, though. I should probably set up a test system to try it.

  296. nomos


    I use WP 3.0.1 withe the multisite feature. The problem of my plugin ”search weverything” is, that´s not possible to select the different blog in the results.

    If I seach in blog A – I wish only results from blog A and if I search in blog B only from B. In this time I have a mixing in the results.

    Is Relevanssi the solution for my?


  297. Mikko Saari

    1) It’s hard to say why without further data.

    2) Are you running the latest version of Relevanssi (2.1.1)? Some recent versions had problems with phrases. It should work just like that.

    3) Boolean operators aren’t generally used in partial matching. I’m not sure if they are worth supporting, as most people (I’m guessing here, but 99% is probably too low) don’t use them. And will just restrict the number of results, as results featuring all terms are bound to appear on the top anyhow. Partial matching has implicit or between the words. Nobody except trained professionals constructs more complex queries. Minus operator might be useful and maybe plus (force this to appear), but even those are probably fairly rare in actual use.

    4) No, not right now. You can set it so that partial matches are only returned if complete matches are not available, see the setting for fuzzy matching.

    5) Yes, but not in the search itself. I suppose I could add the feature. However, it would probably be easier for users to have a dropdown box with possible categories to choose from. Just name the dropdown variable ”cat”. That works with custom taxonomies, too, but not with custom fields (WordPress doesn’t allow it). To be honest, this is a low-priority feature, as again while it’s helpful, it’s also something most searches will never use, as it’s too complicated. Searchers prefer simple.

    6) That’s possible, sure.

  298. Mohib

    Hi, I’m testing your plugin and it seems to work very well, but I’m having some problems and questions:

    1) All the hits found aren’t returned in the results. For example one search returns 13 hits (my search results page indicates this), but only 10 are listed with the snippets. If I turn Relevanssi off then the default WordPress also indicates 13 hits found and all 13 are listed.

    2) How do I search for a phrase like ”nursery school” in quotes? If I try this I get ”0” results.

    3) I can’t seem to be able to use boolean operators like ”and” ”or” as they are treated as words. Do you plan to support them?

    4) If I search for ”May” partial words are returned. Is there anyway to force it to use full words and then use * for parital words, i.e ”May*”?

    5) Is there any way to specify which categories to limit the search to in the search string? For example something like:
    nursery school cat:USA cat:private
    which would limit the search to those posts with ”nursery”, ”school” and tagged with both the USA and private categories.

    Similarly for custom fields, is there a way to specify to search in side a custom field? Say something like:
    nursery school custom:type_of_method:montessori
    which would find posts with ”nusery”, ”school” and the value ”montessori” in the custom field called ”type_of_method”
    6) Also I’m also testing, but it doesn’t seem as stable as Relevanssi, but it has a very nice feature that highlights the words in the actual post when I open it which is very cool and useful. Do you have any plans to do such a feature?

    I’m using wordpress 3.0.1.

    Thanks for your help.

  299. Li-An

    The new ”suggest function” works great ! Thank you for this improvement.

  300. Mikko Saari

    Erik, good to hear everything’s fine. With Relevanssi, you can pretty much expect trouble with new version, unless they’re of the x.x.1 sort.

    Michael, searching child categories is possible to add to the plugin. I’ll see what I can do about it, but right now I don’t have time for the plugin. Vacation over and back to work, unfortunately…

  301. Erik

    Thanks! Just updated to the last version and that fixed it!! Thanks again for this plugin!!!

  302. Erik

    Hey Mikko and all users! 🙂

    I installed Relevanssi, which seems to be a fricken good plugin, but my search results are still always sorted by date… is there any special settings that need to be activated for the search to ignore date, or at least make the date be equal important to title, tag and content?


  303. Michael

    Hi there, great plugin.
    I am using another plugin called search by category, that allows users to limit the category they are searching in for results.
    This works great with your plugin, however, my problem is with your plugin active it does not include child categories of a selected category in the search results.
    Searching for results in a single category works fine, same if searching in the child category. However it would be great to be able to search the parent category, and have the child categories included.
    Is this possible at all?

  304. Randy

    yep, the exclusion works fine now. Thanks for the fast update and responsiveness!

  305. Tailleur d'Images

    yes, I didn’t refreshed my wordpress, since i wait for it’s improvements…
    The new version 2.0.2 of Relevanssi is perfect, the nasty bug is gone !
    Thx ! 🙂

  306. Mikko Saari

    You’re using an older version of WordPress, probably 2.8.5? Anyhow, the version 2.0.1 fixes this bug, so just update and it should be ok.

  307. Tailleur d'Images


    I’m using Relevanssi for a few month, and it is really an improvement as this plugin is really good.
    But I since I downloaded the last version yesterday, my blog bugged : I get a blnk page with a fatal error message that says

    Fatal error: Call to undefined function get_taxonomies() in /homepages/16/d318638819/htdocs/wp-content/plugins/relevanssi/relevanssi.php on line 349

    I couldn’t fix it (no wonder ^^), si I just activated the last version of the plugin, that is still doing well.

    Thanks for the plugin !

  308. Mikko Saari

    You’re correct, it doesn’t work. There’s a bug in the code (this is a part that somebody else added in the code, he used a different naming condition and I referenced to a form variable with a wrong name). Looks like I’m releasing 2.0.1 tomorrow. Thanks for letting me know about the bug!

  309. Randy

    Tried your plugin today. Works better than WP search that’s for sure, but I cannot get it to save the exclude pages. I enter their ID#s separated by commas in the settings field, hit SAVE and the settings page reloads with that field blank again. Searches after this still pull up pages from my exclude list. What am I doing wrong?

    Example: It’s pulling words from my ARCHIVES page and there’s simply no need for that.

  310. Mikko Saari

    I’ve tried and I’ve tried, but I can’t get Relevanssi to activate on random queries. I just don’t understand WP functions well enough to make it work. The query variables simply don’t make any sense.

    So, sorry James, but I don’t know how to do what you want.

  311. James John Malcolm

    Oh wow, Similar Posts works a treat, thank you very much for recommending it.

    I will try and force the search by setting $wp_query->is_search as true, just to see if it works. Checking query var ”s” is probably cleaner, but I dunno if my php-fu is up to scratch.


  312. Mikko Saari

    Since the relevanssi_query function is attached to the_posts hook, it gets triggered every time a list of posts is accessed. So – if you can come up with a way to replace that is_search with something else that recognises when you want to use Relevanssi and when not, then yes, you can get it to work. But I don’t know how to do it… The problem is, ultimately, in the fact that WordPress doesn’t really have an API for something like this.

    Actually, I do have an idea: maybe you could try checking the query vars to see if query var ”s” is set? I’m not sure how you can access the query vars if you use a new WP_Query object, but if you use get_posts, it just might work. Looking at WordPress source code gives me another idea – can you force the search by setting $wp_query->is_search as true?

    In any case, for related posts I’ve been using Similar Posts, which is pretty good.

  313. James John Malcolm

    I’ve started using it on my site too today. It works very well for searches, many thanks for creating it!

    There is one niggle however: due to how Relevanssi hooks into wordpress’ search function, it doesn’t kick in when you do a ”new WP_Query” or a ”get_posts” somewhere in your template. I’ve been playing around with line 348 (if (is_search…etc), but I can’t quite get it to work.
    I’m using it for a related posts function, where the url is broken down into meaningful words and then ”$s_loop = new WP_Query(’s=’. $search_term . ’&showposts=5’);” does (used to do..) its magic.

  314. Nils

    I use this on one big blog for a football club. It works great. Thanks!

  315. Carlos

    Have crossed the messages.

    Your solution works correctly

  316. Carlos

    Solution for highlighting and Warning: mb_strpos() [function.mb-strpos]: Empty delimiter in /var/www/vhosts/ on line 1085

    this happens when you leave a space after the word

    solution: in line 420 replace:
    $t = explode(” ”, $q));
    $t = explode(” ”, trim($q,” +”));

  317. Mikko Saari

    Doesn’t happen on my web sites, but I suppose it’s possible. I’ll fix it in the next release, there’s a fairly simple fix for it. On line 1082 (after the foreach), put ”if ($term) {” and after line 1094 put ”}”. That’ll remove the warning.

  318. Carlos

    Warning: mb_strpos() [function.mb-strpos]: Empty delimiter in /var/www/vhosts/ on line 1085

    this happens when you leave a space after the word