Help save net neutrality! Learn more.

Biblio search does not work

  • IasminB

    IasminB - 2012-11-26

    Hello there,
    Thank you for this great software. I just want to mention a problem that I found with the search.
    I tried to use the Bibliography Search to search for a Title and I found that it is not even case sensitive but worse. The BiblioSearchQueary.php file, on line 78 has a strtolower() function which makes all text to lower case but then there is no such function for the SQL and this results in the search never to work, unless all the titles are written in lower case.
    I suggest that this be changed so that it would function with case insensitive.
    Thank you.

  • Fred LaPlante

    Fred LaPlante - 2012-11-26

    I just tested ver 0.71 with my personal 1300 volume library. I searched for 'mysql', 'MTSQL', and 'MySqL' and all three tests found the same 5 volumes.  This was using the default keyword option. I retested with option Author using 'mysql' and got a hit on a volume having a Title of 'MySQL. I tried option Subject and again got hits.

    Then I went to phpMyAdmin and tried "SELECT * FROM `biblio` WHERE ('a' LIKE 'A')
    The result was a complete list of the table as I would expect.

    So it appears that the mySQL 'like' operator is case insensitive.

    Hope this is helpful.

    Fred LaPlante

  • Hans van der Weij

    I would be surprised if removing strtolower() is the ultimate fix. Did you make that change yourself and is search working right now?
    As Fred explains, the usual behaviour for the MySQL LIKE operator is case insensitive.

    The problem described here may be related to multibyte characters. Are your records not in a western script?

    Also related may be a character set for the database that differs from the character set that is the default for the MySQL server. What is the character set for the OpenBiblio database?
    To check this, a tool like phpMyAdmin may be convenient (look for the "Collation" column). Or perhaps you remember the command you have used for creating the OpenBiblio database. If you used copy/paste from version 0.7.1 install_instructions you would have entered: create database OpenBiblio /*!40100 default character set latin1 */;

    If the database character set is latin1, I do not expect OpenBiblio search to behave case sensitive. But I have seen reports about search becoming case sensitive with utf8. Do you need a fix for case insensitive search with utf8?

  • IasminB

    IasminB - 2012-12-04

    Hello there,
    I'm sorry for the late reply. Thank you for both your replies.
    I agree that LIKE should work but for some reason it does not. My database info: charset=latin1 and COLLATE=latin1_bin. My Admin -> Library Settings -> HTML charset: iso-8859-1.
    I get the same problem with Member search. I have to type them all in small case in order to work.
    I did change the classes/Query.php file as well in order to get Bibliography search going with the change made to classes/BiblioSearchQuery.php. I commented out lines 209-211:

    foreach (explode('.', $arg) as $ident) {
                array_push($a, '`'.$this->_ident($ident).'`');

    and instead of it I put this:

    $SQL .= "LOWER($arg)";

    This got me to be able to write lower case or upper case in Bibliography but it seems like it made it so that the Member search works only if I type in lower case which I think wasn't happening before this change.
    Thank you for trying to help out.

  • IasminB

    IasminB - 2012-12-04

    Here is some more information
    In classes/BiblioSearchQuery.php at line 193 there is this commented out line


    I removed the comment and this is what I got:

    Without my changes:

    select sql_calc_found_rows biblio.* ,biblio_copy.copyid ,biblio_copy.barcode_nmbr ,biblio_copy.status_cd ,biblio_copy.due_back_dt ,biblio_copy.mbrid from biblio left join biblio_copy on biblio.bibid=biblio_copy.bibid where (`biblio`.`title` like '%inima%' or `biblio`.`title_remainder` like '%inima%' ) order by `title` limit 0, 10

    (FYI: the "," between the columns should be fixed) This returns 8 results where the word "inima" was in small caps.

    With my changes:

    select sql_calc_found_rows biblio.* ,biblio_copy.copyid ,biblio_copy.barcode_nmbr ,biblio_copy.status_cd ,biblio_copy.due_back_dt ,biblio_copy.mbrid from biblio left join biblio_copy on biblio.bibid=biblio_copy.bibid where (LOWER(biblio.title) like '%inima%' or LOWER(biblio.title_remainder) like '%inima%' ) order by LOWER(title) limit 0, 10

    This returns 9 results. The extra one is written with Upper case i.

    I tried also to search using the PHPMyAdmin Search function for the biblio table. When I searched using LIKE %inima% I got bibid: 9. When I searched using LIKE %Inima% I got bibid: 7. So this shows me that LIKE is not case sensitive, at least for me. I am using MyISAM storage engine, if that would help.

    In my server variables and settings I have this variable "lower case file system" which is set to ON. I don't know if that would affect anything…
    I also have these variables:

    character set client = utf8
    (Global value) = latin1
    character set connection = utf8
    (Global value) = latin1
    character set results = utf8
    (Global value) = latin1
    collation connection = utf8_general_ci
    (Global value) = latin1_swedish_ci

    I hope that this help in narrowing down the problem. Thank you again.

  • Hans van der Weij

    As I understand it, searching on a database with collation latin1_bin would be case sensitive.

    Collations ending with _ci are Case Insensitive, examples are latin1_swedish_ci and latin1_general_ci

  • Newtron35

    Newtron35 - 2013-01-31

    I'm not sure that this results from the issue listed here, but in search for keywords, the search function looks for all instances of the word, even if the word could be part of another word.  For example: searching for the keyword "sea" results in the normal results but also will include words such as search, sear, seal, seat, seasons… and on. 

  • Hans van der Weij

    You are right about OpenBiblio search, but is not related to the issue above. For replies on how OpenBiblio search finds words, it is preferred to open a new topic in this forum.

    Did you know that search results for "sea" even will include "research"?  In other library systems you would have to search for *sea*  (and in many cases leading wildcards are not supported).

    I think you are the first to comment on this, even though this is how OpenBiblio search works in all versions up to now.

    The development team is researching how to support larger databases, using some type of indexing in a future version of OpenBiblio.  When this is implemented (not soon), there will not be automatic double wildcards for all words.
    We haven't planned to change search in the current development branch (but plans can change when someone offers work for pay).


Log in to post a comment.