mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add ElasticSearch support
This commit is contained in:
+21
-2
@@ -190,8 +190,27 @@ class Predb extends Model
|
||||
}
|
||||
$sql = self::query()->leftJoin('releases', 'releases.predb_id', '=', 'predb.id')->orderByDesc('predb.predate');
|
||||
if (! empty($search)) {
|
||||
$sphinx = new SphinxSearch();
|
||||
$ids = Arr::pluck($sphinx->searchIndexes('predb_rt', $search, ['title']), 'id');
|
||||
if (config('nntmux.elasticsearch_enabled') === true) {
|
||||
$search = [
|
||||
'index' => 'predb',
|
||||
'body' => [
|
||||
'query' => [
|
||||
'match' =>['title' => $search],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$results = \Elasticsearch::search($search);
|
||||
|
||||
$ids = [];
|
||||
foreach ($results['hits']['hits'] as $result) {
|
||||
$ids[] = $result['_source']['id'];
|
||||
|
||||
}
|
||||
} else {
|
||||
$sphinx = new SphinxSearch();
|
||||
$ids = Arr::pluck($sphinx->searchIndexes('predb_rt', $search, ['title']), 'id');
|
||||
}
|
||||
$sql->whereIn('predb.id', $ids);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user