Oct 30 2005

Finally got LiveSearch working

Published by jaseone at 10:25 pm under Information Technology, Wordpress

[tag]Wordpress[/tag][tag]plugin[/tag]I finally worked out that LiveSearch was barfing when the search term was 3 characters or less (probably because of some MySQL error or timeout) so I modified the Javascript used to wait for 4 characters or more before firing off the search.

I still need to tweak the CSS to fit my theme but at least it isn’t throwing ugly PHP errors now and functionally works but the search algorithm is pretty weak:

where post_content LIKE '%$item%'"

Might have to do something about that…

EDIT: ARGH! It is still borked for certain terms like “girl”, WTF? I think it is something wonky with get_permalink, maybe the posts with girl in them have some weird characters in them or something.

EDIT2: Seems like there is a bug in template-functions-links.php on line 92:

$pagestruct = $wp_rewrite->get_page_permastruct();

Commenting that out seems to fix the problem but now to find out why *scratches head*

4 responses so far

4 Responses to “Finally got LiveSearch working”

  1. Jeramyon 31 Oct 2005 at 8:51 am

    You know, you always find the coolest Wordpress plugins.

  2. jaseoneon 31 Oct 2005 at 9:23 am

    That one has been around for a while actually I just couldn’t get it to work on SVN. I still can’t work out what is wrong with that line from template-functions-links.php so I’ve temporarily replaced it with just setting the permalink structure for pages manually.

    The problem was always with that line, it is just that search terms 3 characters or less were more likely to return one of the static pages and that was breaking the code, for some reason I just hate dealing with classes in PHP, don’t ask me why but they just feel wrong so it is taking me a while to figure it out.

  3. Jeramyon 31 Oct 2005 at 9:30 pm

    I also think you were getting the error because mysql’s ft_min_word_len is set to 4, meaning that a word has to be at least 4 characters. It’s on this page: http://dev.mysql.com/doc/refman/4.1/en/myisamchk-general-options.html
    Hope that helps explain why the error was happening.

  4. jaseoneon 31 Oct 2005 at 10:43 pm

    That is what I was thinking at first but my posts table is tiny in the scheme of things so not using the index isn’t a big deal and the query still returns quite quickly.

    It is something to do with the quoted line in core Wordpress, I just don’t know what exactly.

Trackback URI | Comments RSS

Leave a Reply