Query not working on proper nouns.

Discussion in 'MySQL' started by nfzgrld, Jun 25, 2006.

  1. #1
    I have a database built in mysql that is full of religious texts. The bible, quran, bahagavad gita, etc. It's all in there by chapter and verse. I wrote a search engine a few years ago and have adapted it to search this database. I've found something very strange going on. If I do a search on the word "prophet" I get back referances to Mohammed, Moses, Abraham, etc. as you would expect. If a do a search on any of their names I get nothing. If I do a search on ANY name, Jesus, Mary, whoever, I get nothing. The same is true for names of cities and countries. If I search on the word "City" I get back referances to Jeruselem, Mecca, etc. If I search on their names I get nothing. What the hell?

    Here's the query I'm using:
    
    mysql_query("SELECT * FROM scripture WHERE MATCH(info) AGAINST('$qfnd' IN BOOLEAN MODE)");
    
    Code (markup):
    This works great in other applications, and is not case sensitive. I'm not sure what the hell to do with it. If I can't search on proper nouns then the application is fairly useless!
     
    nfzgrld, Jun 25, 2006 IP
  2. iconv

    iconv Well-Known Member

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #2
    If you want to you can send me the schema and I'll take a closer look. For now, make sure that the fulltext index is created on the info field, and that this field actually contains the data you're looking for. If this all checks out ok, try regenerating the index.
     
    iconv, Jun 25, 2006 IP
  3. nfzgrld

    nfzgrld Peon

    Messages:
    524
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I've been though all that. In fact, if I do a search on the word City I get back referances to specific cities. If I search on the name of the city I get nothing. The fulltext index is there, and everything works great as long as I'm not searching on a proper name. This is way to strange for me, I'm begining to think God is play a joke on me.
     
    nfzgrld, Jun 26, 2006 IP
  4. nfzgrld

    nfzgrld Peon

    Messages:
    524
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here's another thing. I just ran the same query in phpMyAdmin and it worked great. Could it be a limitation of the mysql_query() function in php? Wait, phpMyAdmin IS php. Duh! Something ain't right though, I hate this!
     
    nfzgrld, Jun 26, 2006 IP
  5. nfzgrld

    nfzgrld Peon

    Messages:
    524
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok, I found the problem. At least I think I did. After I do the BOOLEAN search I sort the results by doing a substr_count() on the field. When I do an AND logic search I have to strtolower the field to do the substr_count. This is also true if I do an EXACT logic search using no BOOLEAN. If I do an OR logic search I don't have to. This doesn't make any sense to me, but at least it works.
     
    nfzgrld, Jun 26, 2006 IP