Submit Your Article Forum Rules

Results 1 to 2 of 2

Thread: PHP MYSQL FULLTEXT Misbehaving

  1. #1
    Senior Member
    Join Date
    Apr 2006
    Location
    Boulder, CO USA
    Posts
    371

    PHP MYSQL FULLTEXT Misbehaving

    I set up a mysql table with some fields as a FULLTEXT index.
    The mysql crunching is done via PHP.

    It works - for the most part.

    Here is the issue. I am using an AJAX autocomplete that throws up the results as each character is typed into a text box (This is a search feature). The php program does get called with each character after the first 3 are typed (the php file writes to a log file for each character typed.)

    I get results returned for
    AGAINST ('+bird' IN BOOLEAN MODE)
    AGAINST ('+bird ' IN BOOLEAN MODE)
    AGAINST ('+bird +f' IN BOOLEAN MODE)
    AGAINST ('+bird +fe' IN BOOLEAN MODE)
    AGAINST ('+bird +fee' IN BOOLEAN MODE)

    No results for this (The php mysql_num_rows for the "no results" is zero.)
    AGAINST ('+bird +feed' IN BOOLEAN MODE)

    No results for
    AGAINST ('+bird +feede' IN BOOLEAN MODE)

    Then results are returned for
    AGAINST ('+bird +feeder' IN BOOLEAN MODE)

    This is puzzling me to my wits end.
    I run the query in phpMyAdmin and get plenty of rows returned for '+bird +feed' and '+bird +feede'.
    (Yes, it's the same query php runs - I have that in the log and copy-n-paste into phpMyAdmin).

    I can type the characters into the textbox ever so slowly and same result.

    Can you see what is preventing no results for the interim searches?
    And, how to fix it?

    ---------- Post added at 11:15 PM ---------- Previous post was at 10:03 PM ----------

    I added * at the end of each search term and am now getting results for the no results.
    Can anyone explain why I didn't above?
    And why results were returned for the first grouping? There is no full word, "fe" or "fee" in the database fields.
    And, why the php program returned zero rows when phpMyAdmin would with the exact same query on the same db.

  2. #2
    WebProWorld MVP TrafficProducer's Avatar
    Join Date
    Jul 2003
    Posts
    1,958
    Check collation, characters used

    collation different from character_set_server or collation_server. Case sensitivity of stopword lookups depends on the server collation. For example, lookups are case insensitive if the collation is latin1_swedish_ci, whereas lookups are case sensitive if the collation is latin1_general_cs or latin1_bin.
    FULL TEXT will not do any less than I think it is 4 characters.

    Boolean Full-Text Searches

    http://dev.mysql.com/doc/refman/5.1/...t-boolean.html

    Full-Text Search Functions

    http://dev.mysql.com/doc/refman/5.1/...xt-search.html

    And there are

    Full-Text Stopwords

    http://dev.mysql.com/doc/refman/5.1/...stopwords.html


    If a word is specified with the truncation operator, it is not stripped from a boolean query, even if it is too short (as determined from the ft_min_word_len setting) or a stopword. This occurs because the word is not seen as too short or a stopword, but as a prefix that must be present in the document in the form of a word that begins with the prefix. Suppose that ft_min_word_len=4. Then a search for '+word +the*' will likely return fewer rows than a search for '+word +the'
    Last edited by TrafficProducer; 03-12-2013 at 07:27 PM. Reason: Better links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •