Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2015

    Unanswered: Advanced keyword search with keyword list in an array

    Hi all,

    I am implementing advanced search on a MySQL table.

    I get the keywords in separate arrays:

    allKeywords = []; //use all keywords from this array
    exactKeyWords = []; //use exact phrase from this array
    noKeywords = []; //Not operator

    In my previous assignments I've used full-text searches like this:

    SELECT * FROM report WHERE MATCH (title,toc,overview,meta_keywords)
    AGAINST ('+surgical "growth rate" -operations' IN BOOLEAN MODE);

    Now I need to pass the keywords in arrays. Can any one help how I turn the above query to accomodate array variables.

    If you can site a tutorial or example that will also help me.

    Thanks a lot,

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 10
    Why pass it as an array? Why not pass the keywords in as a string - that would be much easier for MySQL to handle in the syntax you've posted above.
    Home | Blog

  3. #3
    Join Date
    Mar 2015
    Thanks George.

    So if I can convert my arrays to strings,

    $allWords = 'Apple, Banana, Orange';
    $noWords = 'Rose, Lilly';
    $exactWords = '"plants", "trees"';

    can I use my queries like this:
    SELECT * FROM report WHERE MATCH (title,toc,overview,meta_keywords)
    AGAINST ('+$allWords +"$exactWords" -$noWords' IN BOOLEAN MODE);

Tags for this Thread

Posting Permissions

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