function apachesolr_autocomplete_get_stopwords in Apache Solr Autocomplete 6
Same name and namespace in other branches
- 7.2 apachesolr_autocomplete.module \apachesolr_autocomplete_get_stopwords()
- 7 apachesolr_autocomplete.module \apachesolr_autocomplete_get_stopwords()
Gets the current stopwords list configured in Solr.
1 call to apachesolr_autocomplete_get_stopwords()
File
- ./
apachesolr_autocomplete.module, line 436 - Alters search forms to suggest terms using Apache Solr using AJAX. Thanks to robertDouglass who contributed some of the code.
Code
function apachesolr_autocomplete_get_stopwords() {
static $words = array(), $cached_flag = false;
if ($cached_flag) {
return $words;
}
$stopwords_url = "/admin/file/?file=stopwords.txt";
$host = variable_get('apachesolr_host', 'localhost');
$port = variable_get('apachesolr_port', 8983);
$path = variable_get('apachesolr_path', '/solr');
$url = "http://{$host}:{$port}{$path}{$stopwords_url}";
$result = drupal_http_request($url);
if ($result->code != 200) {
return array();
}
$words = array();
foreach (explode("\n", $result->data) as $line) {
if (drupal_substr($line, 0, 1) == "#") {
continue;
}
if ($word = trim($line)) {
$words[] = $word;
}
}
$cached_flag = true;
return $words;
}