Last active
March 15, 2016 13:07
-
-
Save krlucas/5568644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = MyModule | |
description = My Module | |
core = 7.x | |
package = MyModule | |
php = 5.2.4 | |
dependencies[] = views | |
files[] = mymodule_handler_filter_fulltext.inc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_data_alter(). | |
*/ | |
function mymodule_views_data_alter(&$data) { | |
// Adds direct parse mode views fulltext filter to the Default Node Index. | |
$data['search_api_index_default_node_index']['mymodule_views_fulltext'] = array( | |
'group' => t('Search'), | |
'title' => t('Fulltext search using Solr/Lucene syntax'), | |
'help' => t('Search several or all fulltext fields using direct Solr/Lucene syntax.'), | |
'filter' => array( | |
'handler' => 'MyModuleViewsHandlerFilterFulltext', | |
), | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Views Search API fulltext field handler that supports direct searches. | |
* | |
* Note that the tokenizer processor must be disabled. | |
*/ | |
class MyModuleViewsHandlerFilterFulltext extends SearchApiViewsHandlerFilterFulltext { | |
/** | |
* Add this filter to the query. | |
*/ | |
public function query() { | |
// Set parse mode to direct so the search input is sent directly to Solr. | |
$this->query->setOption('parse mode', 'direct'); | |
parent::query(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment