Sets a full text search query. Factual will use this value to perform a
full text search against various attributes of the underlying table, such
as entity name, address, etc.
public search ( $term ) : obj | ||
return | obj | Query |
private function testMultiCountry() { $requestSample = 10; $query = new FactualQuery(); $query->search("Sushi"); $query->field("country")->in(array("US", "CA")); $query->limit($requestSample); try { $res = $this->factual->fetch($this->testTables['global'], $query); } catch (Exception $e) { $this->msg(__METHOD__, false, $e->getMessage()); } if ($res->size() !== $requestSample) { $this->msg("Multi Country Search", false); } else { $this->msg("Multi Country Search", true); } }
if (!$page || $page < 0) { $page = 0; } /** simple search interface */ print "<div id=\"searchcontent\">\r\n"; /** form */ print "<form class=\"searchform\" name=\"input\" action=\"./\" method=\"get\">\r\n"; print "<b>search</b> for <input class=\"search\" type=\"text\" value=\"" . $q . "\" name=\"q\"/> in "; print "<b>postcode</b> <input class=\"postcode\" type=\"text\" value=\"" . $zip . "\" name=\"postcode\"/>"; print "<input type=\"submit\" value=\"search\">\r\n"; print "<input type=\"checkbox\" name=\"categories\" value=\"312,347\"" . $filter . "/>Only Search Restaurants & Bars"; print "</form>\r\n"; try { /** make the query */ $query = new FactualQuery(); $query->search($q); $query->offset($page * PAGE_SIZE); $query->limit(PAGE_SIZE); $query->includeRowCount(); $query->threshold("default"); // see http://developer.factual.com/search-placerank-and-boost/#existence if ($zip) { $query->field("postcode")->equal($zip); } if ($cats) { $query->field("category_ids")->includesAny(explode(',', $cats)); } $res = $factual->fetch("places-us", $query); $data = $res->getData(); $firstRow = $page * PAGE_SIZE + 1; $lastRow = $firstRow + $res->getIncludedRowCount() - 1;