29
The Search API in Drupal 8 Thomas Seidl (drunken monkey)

The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

  • Upload
    others

  • View
    19

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

The Search API in Drupal 8

Thomas Seidl (drunken monkey)

Page 2: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

DisclaimerEverything shown here is still a work in progress.

Details might change until 8.0 release.

Page 3: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

● Generic information● Data sources● Fields● Processing

● Search what?

Basic architectureServer Index Views

Facets

● Technical implementation● Uses database/Solr/…● Search how?

Page 4: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Server●Configuration entity

●Uses „backend“ plugin for operations

●Stores plugin and specific settings

Page 5: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Backend●Plugin for servers

● Implementation of server operations

● Indexing, deleting, searching

● Reaction to changed indexes

● Custom configuration form

●Connects to storage (DB, Solr, …)

Page 6: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Index●Configuration entity

●Main connection to other modules

●Plugins:

● „Datasources“ provide data

● „Tracker“ tracks indexed data

● „Processors“ alter data/workflow

Page 7: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Datasource● Index plugin providing a specific kind of data

● E.g., nodes, comments, external data

●Loading, viewing, metadata for types

●Datasource-specific configuration

Page 8: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Tracker● Index plugin tracking state of items

●Reacts to new/changed/deleted items

●Which items still need to be indexed?

Page 9: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Processor● Index plugin changing data/workflow

●Alter indexed items and search queries

●Configurable

● (Fused with D7 „data alterations“)

Page 10: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

IndexingDatasources Processors

Server

Index1. Determines changed items

2. Load items5. Extracts fields 4. Alter metadata

6. Preprocess fields / items

3. Provide metadata7. Sends items to server

8. Indexes items9. Returns indexed

items

10. Marks items as indexed

Tracker

Page 11: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

SearchingQuery Processors ServerSearch

3. Parses keywords1. Creates query 6. Preprocess query

8. Postprocess search results4. Adds filters, sort,

etc.

7. Retrieves results

5. Executes query

2. Adds keywords

9. Displays results

Page 12: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Customizations

Page 13: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Backend plugin● Integrate Search API with new engines/** * @SearchApiBackend( * id = "MODULE_my_service", * label = @Translation("My backend"), * description = @Translation("Really cool!") * ) */class MyService extends BackendPluginBase { function indexItems($index, $items) {} function deleteItems($index, $ids) {} function deleteAllIndexItems($index) {} function search($query) {}}

Page 14: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Backend plugin●Also available:

● Configuration form

● React to new/changed/removed indexes

● CRUD „hooks“

●supportsFeature(), supportsDatatype()

Page 15: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Features●Add backend-specific functionality

●Defined by contrib modules

●Using modules check for support

●Creation: No code, just documentation

●E.g.: facets, MLT, autocomplete, spellcheck

Page 16: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Data type●Let backends support non-default data types

● E.g., location coordinates, special text formats

●Backends state support similar to features

●Provided as plugins

●Documentation important

Page 17: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Datasource●Support for custom item types/** * @SearchApiDatasource( * id = "MODULE_my_datasource", * name = @Translation("My datasource"), * description = @Translation("My great type.") * ) */class MyDatasource extends DatasourcePluginBase { function getPropertyDefinitions() {} function loadMultiple($ids) {} function getItemId($item) {} function getItemIds() {} // …}

Page 18: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Datasource●Also available:

● Configuration form

● Viewing and view modes

● Get item's ID, label, URL

●Call search_api_track_item_*()!

Page 19: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Tracker●Change tracking implementation/** * @SearchApiTracker( * id = "MODULE_my_tracker", * name = @Translation("My tracker"), * description = @Translation("It tracks.") * ) */class MyTracker extends TrackerPluginBase { function trackItemsInserted($ids) {} function getRemainingItems($limit, $datasource) {} function getTotalItemsCount() {} // …}

Page 20: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Tracker●Usually default tracker will suffice

●Can also have a configuration form

Page 21: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Processor●Pre-/postprocess indexed items and results/** * @SearchApiProcessor( * id = "MODULE_my_processor", * label = @Translation("My processor"), * description = @Translation("Does stuff."), * stages = { * "preprocess_query" = 0 * } * ) */class MyProcessor extends ProcessorPluginBase { function alterPropertyDefinitions(&$info) {} function preprocessIndexItems(&$items) {} function preprocessSearchQuery($query) {} function postprocessSearchResults(&$response, $query) {}}

Page 22: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Processor●Also available:

●supportsIndex()

● Configuration form

● Default implementation FieldsProcessorPluginBase

● process(), processFieldValue(), processKey(), processFilterValue(), testField(), testType()

Page 23: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Parse modes● Interpretation of keywords

●By default: „direct“, „single term“, „multiple terms“

●Selection when creating search

●Not done yet, but will be pluggable

Page 24: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Query●D7: Pluggable in odd way

●D8: TBD

Page 25: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Further D8 changes●Several data sources per index

●More query functionality (like DB layer)

●Major changes for processors

● Possibly: „query extenders“ / per-query processor config

●Loads of other stuff

Page 26: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

General information

Page 27: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Thank you!

Page 28: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

What do you think?

Page 29: The Search API in Drupal 8 · The Search API in Drupal 8 Thomas Seidl (drunken monkey) Disclaimer Everything shown here is still a work in progress. Details might change until 8.0

Other questions?