class FuzzysearchExcerpt in Fuzzy Search 7
Processor to set the index and search settings. Requires FuzzySearchService.
Hierarchy
- class \SearchApiAbstractProcessor implements SearchApiProcessorInterface
- class \FuzzysearchExcerpt
Expanded class hierarchy of FuzzysearchExcerpt
1 string reference to 'FuzzysearchExcerpt'
File
- includes/
processor_excerpt.inc, line 11 - File for processor excerpt.
View source
class FuzzysearchExcerpt extends SearchApiAbstractProcessor {
/**
* {@inheritdoc}
*/
public function supportsIndex(SearchApiIndex $index) {
return $index
->server() && $index
->server()
->supportsFeature('fuzzysearch');
}
/**
* {@inheritdoc}
*/
public function configurationForm() {
$form['debug_score'] = array(
'#type' => 'checkbox',
'#title' => t('Display scoring'),
'#description' => t('If selected, the completeness and score of the results will be shown below each result, which may be helpful for tuning the display.'),
'#default_value' => FALSE,
);
$form['excerpt_length'] = array(
'#type' => 'textfield',
'#title' => t('Result excerpt length'),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Set the length of the displayed text excerpt containing a found search term. Applies per found term.'),
'#default_value' => 200,
);
$form['max_result_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum result length'),
'#size' => 4,
'#maxlength' => 4,
'#description' => t('Set the maximum length of the displayed result. Set to 0 for unlimited length. Applies per result.'),
'#default_value' => 400,
);
$form['spelling'] = array(
'#type' => 'textfield',
'#title' => t('Minimum spelling score'),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Fuzzysearch tries to highlight search terms that may be misspelled. You can set the minimum threshold, which is calculated as a ratio of ngram hits to misses in a term. 0 may cause a misspelling to highlight everything, and 100 will only highlight exact terms. Enter value between 0 and 100. Changing this setting does not require reindexing.'),
'#default_value' => 30,
);
if (!empty($this->options)) {
$form['debug_score']['#default_value'] = $this->options['debug_score'];
$form['excerpt_length']['#default_value'] = $this->options['excerpt_length'];
$form['max_result_length']['#default_value'] = $this->options['max_result_length'];
$form['spelling']['#default_value'] = $this->options['spelling'];
}
return $form;
}
/**
* {@inheritdoc}
*/
public function postprocessSearchResults(array &$response, SearchApiQuery $query) {
$keys = $query
->getKeys();
if (is_array($keys)) {
foreach ($keys as $key => &$v) {
if (!element_child($key)) {
unset($keys[$key]);
}
}
}
if (!empty($response['results'])) {
$entity_info = entity_get_info($this->index->item_type);
// Better way to check if we have text?
if (isset($entity_info['view modes']['full'])) {
$entities = entity_load($this->index->item_type, array_keys($response['results']));
foreach ($entities as $key => $entity) {
$response['results'][$key]['excerpt'] = fuzzysearch_build_excerpt($entity, $this->index, (array) $keys);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FuzzysearchExcerpt:: |
public | function |
Display a form for configuring this processor.
Since forcing users to specify options for disabled processors makes no
sense, none of the form elements should have the '#required' attribute set. Overrides SearchApiAbstractProcessor:: |
|
FuzzysearchExcerpt:: |
public | function |
Does nothing. Overrides SearchApiAbstractProcessor:: |
|
FuzzysearchExcerpt:: |
public | function |
Check whether this processor is applicable for a certain index. Overrides SearchApiAbstractProcessor:: |
|
SearchApiAbstractProcessor:: |
protected | property | ||
SearchApiAbstractProcessor:: |
protected | property | ||
SearchApiAbstractProcessor:: |
public | function |
Submit callback for the form returned by configurationForm(). Overrides SearchApiProcessorInterface:: |
|
SearchApiAbstractProcessor:: |
public | function |
Validation callback for the form returned by configurationForm(). Overrides SearchApiProcessorInterface:: |
4 |
SearchApiAbstractProcessor:: |
protected | function | Internal helper function for imploding tokens into a single string. | |
SearchApiAbstractProcessor:: |
protected | function | Internal helper function for normalizing tokens. | |
SearchApiAbstractProcessor:: |
public | function |
Calls processField() for all appropriate fields. Overrides SearchApiProcessorInterface:: |
|
SearchApiAbstractProcessor:: |
public | function |
Calls processKeys() for the keys and processFilters() for the filters. Overrides SearchApiProcessorInterface:: |
1 |
SearchApiAbstractProcessor:: |
protected | function | Function that is ultimately called for all text by the standard implementation, and does nothing by default. | 5 |
SearchApiAbstractProcessor:: |
protected | function | Method for preprocessing field data. | |
SearchApiAbstractProcessor:: |
protected | function | Called for processing a single text element in a field. The default implementation just calls process(). | 2 |
SearchApiAbstractProcessor:: |
protected | function | Method for preprocessing query filters. | |
SearchApiAbstractProcessor:: |
protected | function | Called for processing a single filter value. The default implementation just calls process(). | |
SearchApiAbstractProcessor:: |
protected | function | Called for processing a single search keyword. The default implementation just calls process(). | |
SearchApiAbstractProcessor:: |
protected | function | Method for preprocessing search keys. | |
SearchApiAbstractProcessor:: |
protected | function | Determines whether to process data from the given field. | |
SearchApiAbstractProcessor:: |
protected | function | Determines whether fields of the given type should normally be processed. | |
SearchApiAbstractProcessor:: |
public | function |
Constructor, saving its arguments into properties. Overrides SearchApiProcessorInterface:: |
2 |