conjunction OR ++
ajax : keys aren't args any more, because of a+b+c Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
@@ -78,10 +78,13 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
||||
// build the query
|
||||
$index_machine_name = variable_get('autocompletesearchindex', -1);
|
||||
$query = search_api_query($index_machine_name);
|
||||
$query_filter = $query->createFilter();
|
||||
$query_filter->condition('name', $tosearch);
|
||||
|
||||
// $query_filter = $query->createFilter();
|
||||
// $query_filter->condition('name', $tosearch);
|
||||
// $query_filter->condition('type', 'article');
|
||||
$query->filter($query_filter);
|
||||
// $query->filter($query_filter);
|
||||
$query->keys($tosearch);
|
||||
|
||||
$tags_return = $query->execute();
|
||||
// dsm($tags_return, '$tags_return');
|
||||
|
||||
@@ -90,7 +93,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
||||
$index = search_api_index_load($index_machine_name);
|
||||
$delta = 0;
|
||||
foreach ($index->loadItems(array_keys($tags_return['results'])) as $item) {
|
||||
// dsm($item, '$item');
|
||||
//dsm($item, '$item');
|
||||
//$term_matches[$item->tid] = check_plain($item->name);
|
||||
// $term_matches[check_plain($item->name)] = check_plain($item->name);
|
||||
// TODO: leave tags with nodes
|
||||
@@ -125,7 +128,8 @@ function materio_search_api_results_search(){
|
||||
//dsm("materio_search_api_results_search");
|
||||
$args = func_get_args();
|
||||
$typed = implode('/', $args);
|
||||
|
||||
// dsm($typed, 'typed');
|
||||
|
||||
preg_match_all('/\?page=([0-9]+)/', $typed, $pages);
|
||||
//dsm($pages, '$pages');
|
||||
if($pages[0]){
|
||||
@@ -140,12 +144,17 @@ function materio_search_api_results_search(){
|
||||
preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
|
||||
// dsm($words, "words");
|
||||
|
||||
// $escaper = array("+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", '"', "~", "*", "?", ":", '\\');
|
||||
|
||||
// $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
|
||||
// $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
|
||||
foreach ($words[0] as $word) {
|
||||
// $word = preg_replace('/\b-/', '\-', trim($word));
|
||||
// dsm($word);
|
||||
$keys[] = trim($word);
|
||||
$word = trim($word);
|
||||
// $word = str_replace($match, $replace, $word);
|
||||
// dsm($word, 'word');
|
||||
$keys[] = $word;
|
||||
}
|
||||
// dsm($keys, 'keys');
|
||||
|
||||
$index_machine_name = variable_get('mainsearchindex', -1);
|
||||
$index = search_api_index_load($index_machine_name);
|
||||
@@ -160,11 +169,12 @@ function materio_search_api_results_search(){
|
||||
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
|
||||
|
||||
if ($keys) {
|
||||
// TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
|
||||
try {
|
||||
$limit = variable_get($viewmode.'_limite', '10');
|
||||
$offset = pager_find_page() * $limit; //$page*$limit;//
|
||||
|
||||
$query = search_api_query($index_machine_name, array('parse mode'=>'direct'))
|
||||
$query = search_api_query($index_machine_name, array('conjunction'=>'OR', 'parse mode'=>'direct'))
|
||||
->keys(implode(' ', $keys))
|
||||
->range($offset, $limit);
|
||||
|
||||
@@ -174,10 +184,6 @@ function materio_search_api_results_search(){
|
||||
}
|
||||
// dsm($filter, 'filter');
|
||||
$query->filter($filter);
|
||||
|
||||
// $bundle_query_filter = $query->createFilter();
|
||||
// $bundle_query_filter->condition('type', 'materiau');//$bundles_filter);
|
||||
// $query->filter($bundle_query_filter);
|
||||
|
||||
$results = $query->execute();
|
||||
}
|
||||
@@ -314,7 +320,8 @@ function materio_search_api_actuality(){
|
||||
}
|
||||
}
|
||||
|
||||
drupal_set_title(t('Actualities'));
|
||||
// drupal_set_title(t('Actualities'));
|
||||
drupal_set_title(t(''));
|
||||
|
||||
return theme('materio_search_api_actuality', array(
|
||||
'items' => $items,
|
||||
@@ -326,12 +333,11 @@ function materio_search_api_actuality(){
|
||||
|
||||
|
||||
function materio_search_api_viewmode_change($vm){
|
||||
dsm($vm, 'materio_search_api_viewmode_change');
|
||||
//dsm($vm, 'materio_search_api_viewmode_change');
|
||||
$rep = _materio_search_api_change_viewmode($vm);
|
||||
|
||||
//return 'debug mode for materio_search_api_viewmode_change';
|
||||
// drupal_json_output($rep);
|
||||
|
||||
drupal_goto();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user