search api attachments processor

This module is an add-on to the Search API module which allows the indexing and searching of attachments.

The extraction can be done using one of the following methods:

  • Apache Tika App
  • Apache Tika Server
  • The Solr built-in extractor
  • pdftotext for PDFs
  • Python pdf2txt for PDFs
  • golang docconv
  • Unstructured.io (cloud or self-hosted)

Architecture

The module is built on two kinds of plugins :
text extractor plugins convert a file into text
search api attachments extraction methods
file aggregator plugins find which files belong to the entity being indexed.

File aggregator plugins can be enabled together.
only the pluginOne level file fields is enabled by default.

search api attachments aggregator plugins

  • One level file fields
    one step away, on the entity : direct file, image, SVG and media reference fields, plus the file itself when the datasource is File.
    (This is the only plugin enabled by default)
  • One level body text embeds
    one step away, inside the entity : files and media embedded in a formatted text field.
    For example a media entity in a body field.
    The UUID matchers, target entity types and scanned fields are configurable.
  • One level Layout Builder blocks
    one step away, outside the entity fields : inline and reusable custom blocks placed in Layout Builder sections that contain file/media fields or text embeds.
  • One level link fields
    one step away, on the entity : direct link fields pointing to remote files such as a PDF on a CDN.
    The file is downloaded, extracted and cached.
  • Many levels entity references
    more than one step away (nested) : recursively follows entity_reference and entity_reference_revisions fields.
    For example :
    Article node => its paragraphs => their media fields.
    Article node => its paragraphs => referenced Page node => their file fields.
    The nested aggregator does not extract files itself : it only explores entity references and runs the enabled one-level plugins on every referenced entity.
    Nested depth is configurable (default 3).
    Discovery uses BFS Algo to explore entities once avoiding loops.
  • search api attachments One level/Nested levels index fields

Features

  • Indexes files from the core file and image field types, media reference fields, and any field type whose class extends FileItem (e.g. svg_image_field).
  • Extraction cache (stored in key-value or files under private:// or public://), automatic invalidation when a file changes, and a fallback queue for failed extractions.
  • Providing a field formatter ("Text extracted from attachment") and an extra field ("Search API attachments") to display extracted text when needed.
  • Providing a Views filter ("Exclude search in attachments"), so users can include or exclude attachment text in fulltext searches.
  • Per-processor limits : excluded extensions, maximum file size, include/exclude private files, number of files to extract per field, and maximum extracted text size.
  • Some aggregator plugins provide Allowed/Exclude field names, so that user can limit the fields discovered by the plugin.
  • Hooks for custom indexing rules, post-extraction reactions, and non-file media sources such as Acquia DAM. See search_api_attachments.api.php
  • Debug mode, extractor test on save, and config-import validation of aggregator dependencies.

See the README for installation, extractor configuration, aggregator settings, caching, hooks and usage examples.

Drupal 11

The module's D11 version is available.

Drupal 10

10.0.18 is the last pure Drupal 10 compatible version.

Drupal 9

9.0.6 is the last pure Drupal 9 compatible version.

Supporting organizations: 
Sponsored initial developpement of D7 version of this module
Added support of field_collections throw search_api_attachments_field_collections D7 submodule

Project information

Releases