Zach Minner
Drupal 8
WIP

Create a Search page using Search API in Drupal 8

Using Drupal 8's Search API, we'll quickly run through the steps for building a search page.

Grab and enable the Fire Search module

  1. https://github.com/skycatchfire/fire-modules/tree/master/fire_search
  2. drush en fire_search
  3. Update $valid_bundles array on line 31 of fire_search.module to the content types you want to add the Search aggregate field to

Create a Search Keywords taxonomy

Add new fields to content types you will be indexing

  1. Add a Search Aggregate field (Text, (plain, long))
  • Help Text: Automatically populated when saving a node. Used for search.
  1. Add a Search Keywords field (Entity reference) that pull from the Search Keywords taxonomy that you added to each content types that you
  • Should be autocomplete
  • Should allow multiple values
  • Reference Type: Search Keywords
  • Check Create referenced entities if they don't already exist
  • Help Text: A comma-separated list of keywords that will make this content appear in search form suggestions.
  1. Add a Search Description field (Text (formatted, long))
    • This will be displayed on the search page for each result
    • Help Text: Displayed on the search results page.

Enable Database Search and Search API modules

enable modules

Click Add Server button

add server

  1. Fill in fields fill in fields
  2. Save

/admin/config/search/search-api

Click Add Index button

  1. add index
  2. Fill in fields and select datasources you want to index select datasources
  3. Scroll down and configure the datasources you selected datasources
  4. Choose which server the indexes should use

server index 5. Click the Save and add fields button

save

  1. /admin/config/search/search-api/index/content/fields
  2. navigate to fields tab
  3. Click Add fields
    1. Add the fields that should be indexed
    2. Configure Type
    3. Configure Boost to desired value if applicable configure boost
  4. Click Save changes

Click Processors tab

  1. /admin/config/search/search-api/index/content/processors
  2. Enable HTML filter and Ignore case processors

enable filters 3. Scroll down and update Processor settings for HTML filter

filters 4. Update Processor settings for Ignore case

update processor settings for ignore case 5. Click Save

Click View tab

  1. Click the Index now button

start indexing

Create a view

  1. Name it Search
  2. In View Settings, choose Index Content view settings
  3. Click the Create a page checkbox and configure create a page
  4. Click Save and edit

Once on the Search View page, add fields to display and configure

  1. /admin/structure/views/view/search view setup setup fields

    Update Filter/Sort Criteria

    setup filter and sort criteria

    Create templates, output selected fields, style 😃