1
0
Fork 0
mirror of https://github.com/Oreolek/oreolek.ru.git synced 2024-04-29 15:49:24 +03:00

Sphinx full-text search integration probe

Should implement issue #14.
This commit is contained in:
Alexander Yakovlev 2013-06-28 13:46:24 +07:00
parent b8794cc1b6
commit 84343b496f
8 changed files with 38 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
application/config/database.php
application/config/auth.php
application/config/stats.php
application/config/sphinxql.php
application/cache
application/logs

3
.gitmodules vendored
View file

@ -25,3 +25,6 @@
[submodule "modules/kostache"]
path = modules/kostache
url = git://github.com/zombor/KOstache.git
[submodule "modules/sphinxql"]
path = modules/sphinxql
url = git://github.com/x10d/kohana-sphinxql.git

View file

@ -4,6 +4,11 @@ License is [AGPL 3.0.](http://www.tldrlegal.com/l/AGPL3)
Oreolek.
## Requirements
* Kohana 3.3
* MySQL or MariaDB
* Sphinx
## Installation
* `git clone` - I assume you are familiar with this command

View file

@ -114,6 +114,7 @@ Kohana::modules(array(
'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar
'image' => MODPATH.'image', // Image manipulation
'kostache' => MODPATH.'kostache', // Logic-less Mustache views
'sphinxql' => MODPATH.'sphinxql', // Full-text search via Sphinx
// 'cache' => MODPATH.'cache', // Caching with multiple backends
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
// 'unittest' => MODPATH.'unittest', // Unit testing

View file

@ -270,4 +270,22 @@ class Controller_Post extends Controller_Layout {
->limit(10)
->find_all();
}
public function action_search()
{
$term = $this->request->post('term');
if ($term == '')
{
$this->redirect('');
}
$sphinxql = new SphinxQL();
$query = $sphinxql->new_query();
$query->add_index('index1')
->add_field('name')
->add_field('content')
->search($term);
$this->template = new View_Index;
$this->template->title = 'Результаты поиска';
$this->template->items = $query->execute();
}
}

View file

@ -120,4 +120,9 @@ class View_Layout {
}
return $output;
}
public function search_url()
{
return Route::url('default', array('controller' => 'Post', 'action' => 'search'));
}
}

View file

@ -12,9 +12,12 @@
<h1>{{site_title}}</h1>
</div>
<div class = "navigation">
<form action="{{search_url}}" method="POST">
<input type="text" placeholder="Поиск записей" name="term">
</form>
<ul>
{{#navigation}}
<li><a href="{{url}}">{{title}}</a></li>
<li><a href="{{url}}">{{title}}</a></li>
{{/navigation}}
</ul>
</div>

1
modules/sphinxql Submodule

@ -0,0 +1 @@
Subproject commit 0d6e016ffae2bd9da4a642bc5e6388efb2979d7b