public function search($q, $begin = 0, $size = 20) { $url = "http://" . SEARCHSERVER . ":9200/_search/?size={$size}&from={$begin}"; $json = '{ "query": { "multi_match": { "query": "' . $q . '", "fields": ["title","content","replysText","tags"] } }, "highlight" : { "fields" : { "content" : {"type" : "plain"}, "replysText" : {"type" : "plain"} } } }'; return ToolModel::postJSON($url, $json); }
public function dataAction() { $id = $this->intVal(3); $threadModel = new ThreadModel(); $userModel = new UserModel(); $reputation = $userModel->reputation($this->userid); $thread = $threadModel->threadById($id); if (!$thread || $thread["del"] == 1) { header("HTTP/1.1 301 Moved Permanently"); header("location: /home/"); die; } $replys = $threadModel->replysById($id); $replysText = ""; foreach ($replys as $reply) { $replysText .= "{$reply['name']}说道:{$reply['content']}\r\n"; } $thread["replysText"] = $replysText; $url = "http://" . SEARCHSERVER . ":9200/ourcoders/thread/{$id}/"; $data = ToolModel::postJSON($url, json_encode($thread)); echo $data; }