Agrovocfield
Suggests AGROVOC taxonomy tags for content by calling a self-hosted AgroTagger service. Drupal 11 port of the legacy Drupal 7 agrovocfield_automatic sub-module, renamed to agrovocfield for this site.
What it does
When editing content, this module can automatically suggest AGROVOC concept tags for a taxonomy reference field, based on the text in another field on the same content (e.g. the body). It only fills the field when the editor has left it empty â it never overwrites tags an editor picked or already-saved tags.
On save, if automatic indexing is enabled for a field:
- The module reads the just-submitted value of the configured "source" field.
- It calls the self-hosted AgroTagger HTTP service (
POST /tag) with that text. - For each AGROVOC concept returned, it looks up or creates a matching taxonomy term in the field's target vocabulary. Newly created terms get their canonical AGROVOC URI stored in a
field_agrovoc_urilink field, if the vocabulary has one. - It populates the field with those terms before the entity is saved.
This all happens inside an #element_validate callback, so it only runs during interactive form submission â never during programmatic saves, migrations, or content imports.
AGROVOC URI linking
If the target vocabulary has a field_agrovoc_uri link field (as the "Tags" vocabulary on this site does), the module:
- Normalizes the legacy AIMS URI the AgroTagger service returns (
http://aims.fao.org/aos/agrovoc/c_XXXX) to the canonical URL it redirects to today (https://aims.fao.org/aos/agrovoc/c_XXXX.html), avoiding a multi-hop redirect chain on every click. - Stores it on the term, so it renders as a normal clickable link wherever the term's own fields are displayed (e.g. the term's own page, if
field_agrovoc_uriis enabled in its "Manage display" settings).
Separately, the Tagify widget's own built-in "Include info label" setting can show this URI directly inside each tag pill while editing â set the widget's "Info label content" to the token [term:field_agrovoc_uri]. This is a standard Tagify feature, not something this module adds; it just needs field_agrovoc_uri to exist and be populated, which this module handles.
Terms without this field are unaffected. For terms created beforefield_agrovoc_uri existed (or matched by name to a pre-existing term rather than auto-created), the URI isn't set automatically â but it can be backfilled after the fact using the AgroTagger service's GET /lookup?label= endpoint (a direct dictionary lookup against the same labelâURI mapping used for tagging, added specifically for this). There's no UI for this yet; it's a one-time drush php:script that loads every term in a bundle with field_agrovoc_uri, skips any that already have a value, calls /lookup for the rest, and saves the normalized URI for whatever matches. Not run automatically â re-run it manually if more untagged legacy terms show up later.
Requirements
-
A running AgroTagger service reachable from this Drupal installation. See
agrotagger/adr-agrotagger-selfhosted-2026-08-05.mdin this repo for how that service is built and deployed (a Java service wrapping the MAUI keyphrase-extraction library, running as a K3s Deployment/Service in this cluster). -
A taxonomy reference field using one of the two supported widgets:
- Core's Autocomplete (Tags style) widget (
entity_reference_autocomplete_tags) - The Tagify contrib module's widget (
tagify_entity_reference_autocomplete_widget)
These are the only widgets supported â both are "tags style" widgets (a single multi-value element per field, not one element per delta), matching what the original Drupal 7 module supported via core's
taxonomy_autocompletewidget. Other entity reference widgets are silently ignored. - Core's Autocomplete (Tags style) widget (
Configuration
Service connection: Configuration â Content authoring â AGROVOC Field (/admin/config/content/agrovocfield). Sets the AgroTagger service base URL (default http://agrotagger:8080, the in-cluster service DNS name) and the request timeout.
Per-field settings: Structure â Content types â [type] â Manage form display, then the widget settings (gear icon) for the taxonomy reference field. Below the widget's own settings you'll find:
- Enable AGROVOC automatic indexing â on/off for this field.
- Field to index â which other field on the same content supplies the source text.
- Maximum number of tags to suggest â caps how many AGROVOC concepts get applied.
Known limitations
- The AgroTagger service's bundled model (
agrovoc_en) is English-only. Non-English content will produce poor or nonsensical tags â this is a model limitation, not a bug in this module. - Tag suggestions currently have no confidence score (
scoreis alwaysnull) â the underlying service doesn't yet surface one from the legacy MAUI pipeline. See the AgroTagger ADR's "Consequences" section for details. - Requires the source field to be plain or lightly-formatted text; HTML is stripped before sending to the tagging service, but no other content extraction happens (no PDF/file support).
- Backfilling existing terms' AGROVOC URI is a manual one-time script, not an automatic or scheduled process (see "AGROVOC URI linking" above) â it won't pick up newly unlinked terms on its own.