2017 © Pedro Peláez
 

drupal-module searches

Provide a standard way to do searches via search api

image

gertvdb/searches

Provide a standard way to do searches via search api

  • Saturday, July 21, 2018
  • by gertvdb
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Searches

Provide a general wrapper class to execute searches., (*1)

Usage

Using the class., (*2)


use Drupal\searches\Search\Search; use Drupal\searches\Search\Index\Index; use Drupal\searches\Search\Term\Term; use Drupal\searches\Search\Collection\FilterCollection; use Drupal\searches\Search\Collection\SorterCollection; use Drupal\searches\Search\Filters\DataSourceFilter; use Drupal\searches\Search\Filters\BundleFilter; use Drupal\searches\Search\Filters\StatusFilter; use Drupal\searches\Search\Sorters\CreationDateSorter; // Prepare Index. $index = new Index('my_index'); // Prepare filters. $filters[] = new DataSourceFilter(['node']); $filters[] = new BundleFilter(['activity']); $filters[] = new StatusFilter(TRUE); $filter_collection = new FilterCollection($filters); // Prepare sorters. $sorters[] = new CreationDateSorter(); $sorter_collection = new SorterCollection($sorters); // Prepare search term. $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')->createInstance('terms'); $fields = ['title', 'description']; $term = new Term('Test', $parse_mode, $fields); // Prepare search. (Search will not be executed untill method search is called upon object.) $search = new Search($index, $term, $filter_collection, $sorter_collection); // Prepare pagination data. $current_page = 0; $item_per_page = 5; // Fire search. // When no current page or items per page are passed the full result list will be returned. $results = $search->search($current_page, $item_per_page); // Get full result count. $count = $search->searchCount(); // Get facets info. $info = [ 'type' => [ 'field' => 'type', 'limit' => 0, 'min_count' => 0, 'missing' => FALSE, ], ] $facets = $search->searchFacets($info);

The Versions

21/07 2018

dev-master

9999999-dev

Provide a standard way to do searches via search api

  Sources   Download

MIT

The Requires

 

by Gert van den Buijs

21/07 2018

1.0.0

1.0.0.0

Provide a standard way to do searches via search api

  Sources   Download

MIT

The Requires

 

by Gert van den Buijs

21/07 2018

dev-develop

dev-develop

Provide a standard way to do searches via search api

  Sources   Download

MIT

The Requires

 

by Gert van den Buijs