private function ElasticsearchViewsFulltextSearch::getFulltextFields in Elasticsearch Connector 8.6
Same name and namespace in other branches
- 8.7 modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsFulltextSearch.php \Drupal\elasticsearch_connector_views\Plugin\views\filter\ElasticsearchViewsFulltextSearch::getFulltextFields()
- 8.2 modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsFulltextSearch.php \Drupal\elasticsearch_connector_views\Plugin\views\filter\ElasticsearchViewsFulltextSearch::getFulltextFields()
- 8.5 modules/elasticsearch_connector_views/src/Plugin/views/filter/ElasticsearchViewsFulltextSearch.php \Drupal\elasticsearch_connector_views\Plugin\views\filter\ElasticsearchViewsFulltextSearch::getFulltextFields()
Choose fulltext fields from ElasticSearch mapping if they are type string and are analyzed (there is no index => not_analyzed in the mapping)
Return value
array fields
1 call to ElasticsearchViewsFulltextSearch::getFulltextFields()
- ElasticsearchViewsFulltextSearch::buildOptionsForm in modules/
elasticsearch_connector_views/ src/ Plugin/ views/ filter/ ElasticsearchViewsFulltextSearch.php - Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.
File
- modules/
elasticsearch_connector_views/ src/ Plugin/ views/ filter/ ElasticsearchViewsFulltextSearch.php, line 74
Class
- ElasticsearchViewsFulltextSearch
- Default implementation of the base filter plugin.
Namespace
Drupal\elasticsearch_connector_views\Plugin\views\filterCode
private function getFulltextFields() {
$view_id = $this->view->storage
->get('base_table');
$data = Views::viewsData()
->get($view_id);
$index = $data['table']['base']['index'];
$type = is_array($data['table']['base']['type']) ? implode(',', $data['table']['base']['type']) : $data['table']['base']['type'];
$cluster_id = $data['table']['base']['cluster_id'];
/** @var \Drupal\elasticsearch_connector\Entity\Cluster $elasticsearchCluster */
$elasticsearchCluster = \Drupal::service('entity.manager')
->getStorage('elasticsearch_cluster')
->load($cluster_id);
/** @var \Drupal\elasticsearch_connector\ElasticSearch\ClientManagerInterface $clientManager */
$clientManager = \Drupal::service('elasticsearch_connector.client_manager');
$client = $clientManager
->getClientForCluster($elasticsearchCluster);
$params = array(
'index' => $index,
'type' => $type,
);
$mapping = $client
->indices()
->getMapping($params);
$fulltext_fields = array_keys(array_filter($mapping[$index]['mappings'][$type]['properties'], function ($v) {
return $v['type'] == 'text' && (!isset($v['index']) || $v['index'] != 'not_analyzed');
}));
return array_combine($fulltext_fields, $fulltext_fields);
}