DrupalCamp Asheville 2017 presentation on Search API and how to use it. This shows some examples of what you can do with Search API, how it works, how to set it up, and various tweaks and problems to look out form.
2. Why Use Search API?
●
Highly Customizable without Code
●
Google-’lite’ results
●
Results pages from views
●
Multiple indices with a wide range of processors
●
Facet (and other) Results Filtering
●
Can use high performance backends
●
Apache Solr
●
ElasticSearch (D7 only for now)
●
It’s an API so future search engines could be added
3. A Quick Word about
Apache Solr...
●
Is not Search API
●
Has been ‘rolled into’ D8 Search API
●
Modules for Apache Solr will not work with
Search API
4. Sites Showcase
●
Duke Health
( www.dukehealth.org )
●
Wesleyan Holiness Digital Library
( www.whdl.org )
●
SolarWinds MSP
( www.solarwindsmsp.com )
5. Basic Architecture
●
Search Engine
●
Actual Storage / Retrieval
●
Can use database, Solr, and others if Backend exists
●
Search Backend
●
Bridges the standardized Search API with native
Search Engine
●
Search Indices
●
Describes what is indexed and how it is searched
6. Search API Index Overview
Search API Index Search API
Backend
Datasource
Pre-Index
Processors
Field
Definitions
Search
Engine Server
Post Query
Processors
Views
Pre-Query
Processors
Index
Event
Views Filter
Query
Display
Results
Translates Core
API Services To
Native Search
Engine
Supplies
Search Engine
Specific
Features
Facets
7. Which Backend?
●
Solr
●
Designed as fast, full featured search engine
●
Clusterable Java/Jetty Based Webapp (requires
additional service/server)
●
Debugging/Enhancing has steep learning curve
●
DB Backend
●
Full featured and very usable
●
Fast to setup / Easy to debug SQL tables
●
Slower and not a scalable
8. Setup Overview
●
Install Modules / Backend Service
●
Configure Backend Server
●
Configure one or more indices
●
Datasources
●
Fields
●
Processors
●
Populate the indices
●
Create Results View
●
Add Facets
9. Modules and the like
●
Required Items
●
Search API ( www.drupal.org/project/search_api )
●
A Search Backend ( Solr / Database in D8 SAPI)
●
Search Engine Service for backend (Solr / Database)
●
Some useful optional Modules (D8)
●
Facets ( www.drupal.org/project/facets )
●
Autocomplete ( drupal.org/project/search_api_autocomplete )
●
Search API Exclude Entity( drupal.org/project/search_api_exclude_entity)
●
See Handbook for more ( drupal.org/node/1999262 )
11. Define A Search Server
3 is the recommended
min word length
Solr Backend will require
connection information
12. Index Planning
●
Decide what you want to index (e.g. blogs,
full site, and the like)
●
Look at the structure of what you want to
index (e.g. fields, entity references, etc.)
●
Decide if there are any items that should be
more important (e.g. words in title or author
name)
●
Think about the results display and what you
need there, including filtering (facets).
13. The Example Index
●
A Blog index
●
Blog posts have the following fields:
●
Title, body, tags, entity ref to an Author entity, featured
image, date published, status
●
Author names / Words in titles should be
more important
●
The results should have title, author, date,
featured image, highlighted excerpt, and be
filterable by category and month.
14. Define an Index (Datasources)
Select your Datasource(s)
for this index.
Note: Some may not have
the results you expect.
17. Adding Fields
Quick way to
Index everything
All fields defined
for entity
Expandable to
referenced content
Some
Custom Fields
Make sure to click the Done Button!
19. Index Processors
●
“Massage” data being stored or retrieved
●
Modify queries going to the backend
●
Supply custom ‘fields’
●
Can help shape the results
24. Index Views
●
Links index data with ‘datasource’ data (e.g.
index data can map to node fields)
●
Supplies a configurable fulltext search filter
●
Can filter by most indexed fields as well
●
Sortable by relevance or other information
●
Standard views formats, layouts, field features
are available
●
Excerpt field available with optional highlighting
27. Facets
●
Results Subseting not Views Filters
●
Shows only items in the current result set not all
possibilities
●
Supports a wide variety of widgets (drop
downs, dates, sliders, and the like)
●
Can show counts of related items
●
Linked to fields in index views
●
Placed on pages as blocks
32. The Results
●
With some block placement
●
A custom Search form (could be HTML)
●
Some CSS TLC
Www.SolarWindsMSP.com/blog/search
33. Next Steps
●
Search optimization
●
Play with boosts, stop words, synomyms, and the like
●
Filtering out what you don’t want indexed
(search_api_exclude_entity)
●
●