}
// Check if search string is valid.
- if (strlen($search_query) < 4)
+ if (strlen($search_query) === 0)
{
//$results_data['videos'] = NULL;
- $this->error($this->lang->line('error_search_query_too_short'),
+ $this->error($this->lang->line('error_search_query_empty'),
$header_data);
return;
}
<?php
-$lang['error_search_query_too_short'] = 'The search query is too short! You must enter at least 4 characters.';
+$lang['error_search_query_empty'] = 'The search query is empty! Type something to search for or otherwise go to the home page to browse.';
/* End of file error_lang.php */
/* Location: ./application/language/english/error_lang.php */
\ No newline at end of file
*/
public function search_videos($search_query, $offset = 0, $count = 0,
$category_id = NULL)
- {
- if (! $this->is_advanced_search_query($search_query)) // if natural language mode
+ {
+ // very short queries
+ if (strlen($search_query) < 4)
+ {
+ $search_cond = "(title LIKE '%$search_query%'
+ OR description LIKE '%$search_query%'
+ OR tags LIKE '%$search_query%')";
+ $relevance = "( 0.5 * (title LIKE '%git%')
+ + 0.2 * (description LIKE '%git%')
+ + 0.3 * (tags LIKE '%git%') ) AS relevance";
+ }
+ // natural language mode
+ else if (! $this->is_advanced_search_query($search_query))
{
$search_cond = "MATCH (title, description, tags)
AGAINST ('$search_query')";
$relevance = "$search_cond AS relevance";
- } // if boolean mode
+ }
+ // boolean mode
else
{
$against = "AGAINST ('$search_query' IN BOOLEAN MODE)";
$limit = "";
}
else
- {
+ {
+ // TODO select data, description if details are needed
$selected_columns = "id, name, title, duration, user_id, views,
- thumbs_count, default_thumb, date, description,
+ thumbs_count, default_thumb,
(views + likes - dislikes) AS score,
$relevance";
$order = "ORDER BY relevance DESC, score DESC";
var fakeSubmit = function() {
var searchQuery = $('#search').val();
- if (searchQuery.length < 4)
+ if (searchQuery.length === 0)
{
- alert('<?php echo $this->lang->line('error_search_query_too_short') ?>');
+ alert('<?php echo $this->lang->line('error_search_query_empty') ?>');
return;
}