-
-
Save algotrader-dotcom/41d484070d06fbcb08d91f93c7449aee to your computer and use it in GitHub Desktop.
Drupal Search Api Custom Search Example
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 | |
| # http://drupal.stackexchange.com/questions/135918/return-other-indexed-fields-using-searchapiqueryindex | |
| # http://www.phponwebsites.com/2015/12/drupal-7-add-custom-fields-to-search-api-solr-index.html | |
| # https://gist.github.com/acquialibrary/572acdbc4004fbfca02b | |
| # http://drupal.stackexchange.com/questions/115878/search-snippet-does-not-appear-in-search-api-search-page | |
| # Remember disable Tokenizer in Filter (This causes a lot of troubles in highlighting keyword) | |
| $server = search_api_server_load('acquia_search_solr_server'); | |
| $index = search_api_index_load('node_index'); | |
| $query = new SearchApiQuery($index); | |
| $query->condition('type', 'article'); // type must be indexed when configure in backend | |
| $results = $query->execute(); | |
| // Nice results | |
| $solr = new SearchApiSolrService($server); | |
| $res = $solr->search($query); | |
| print_r($res); | |
| // Nice results | |
| print_r($results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment