Skip to content

Instantly share code, notes, and snippets.

@nicholaskajoh
Last active March 15, 2019 13:29
Show Gist options
  • Save nicholaskajoh/348d07e6144367358583d1c2d1759937 to your computer and use it in GitHub Desktop.
Save nicholaskajoh/348d07e6144367358583d1c2d1759937 to your computer and use it in GitHub Desktop.
Keyword search
<?php
$search_query = "cattle rearing"; // example
$search_words = explode(" ", $search_query);
$sql = "SELECT * FROM _index WHERE ";
for ($i = 0; $i < count($search_words); $i++) {
$sql .= "CONTAINS(keywords, '{$search_words[$i]}')";
if ($i < count($search_words) - 1) $sql .= " AND ";
}
echo "SQL Query: " . $sql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment