Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I added "foobar" as a metatag keyword to a node, re-indexed the search index and searched with the core search function for "foobar". I got 0 results.
It would be great if metatags would index all (or selectable) meta tags for the core search function.
Comments
Comment #1
marcoka CreditAttribution: marcoka commentedas far as i know core search indexes content/title field and so on. but not metatags.
Comment #2
no2e CreditAttribution: no2e commentedSo is this not a legitimate feature request for Meta tags?
A (untested) work-around is:
Comment #3
marcoka CreditAttribution: marcoka commentedmeta tag quick uses fields. meta tags doesnt add any fields to your content type. so i think that means restructuring the basical architectural concept.
in my opinion this is a very very unique feature you are requesting.
you use tokens with metatags right? why not just add own fields to the content type and add tokens there. then you can index these fields.
Comment #4
DamienMcKennaComment #5
mstrelan CreditAttribution: mstrelan commentedI think this is a very valid feature request for Metatag, or a perfect candidate for another contrib module. Adding extra fields and hiding them is a PITA, especially since the available metatag fields seems to be constantly evolving. These steps should be a good starting point.
Alternatively, if you only want to implement this for nodes, skip the first 2 steps and implement hook_node_update_index().
Comment #6
DamienMcKennaThis would need hook_node_update_index() to be implemented.
Comment #7
mstrelan CreditAttribution: mstrelan commentedNot necessarily. If the metatags are rendered by node_view() with the search_index view mode then they will be indexed automatically. See https://api.drupal.org/api/drupal/modules%21node%21node.module/function/...
Comment #8
DamienMcKenna@mstrelan: That's true. I think, however, it'd be cleaner to implement hook_node_update_index than to get a bit hacky with view modes in metatag_entity_view.
Comment #9
mstrelan CreditAttribution: mstrelan commentedI'm not fussed either way, and for the project I'm working on I've done a simple implementation of hook_node_update_index().
I would disagree that the view mode approach is more hacky. For one, it automatically would support other entity types, such as file entities (see http://www.drupalcontrib.org/api/drupal/contributions%21file_entity%21fi...). Secondly, that's the exact way fields are included in the index. And finally, this is the same way other contrib modules, such as Commerce, would add their data to the search index.
Comment #10
DamienMcKenna@mstrelan: If using hook_metatag_view with the 'search_index' view mode is how other modules are doing it, then that'd be fine, thanks for taking the time to check others.
Incidentally, there's separate work for integrating search API, so I think it'd be safe to focus on just the core search module: #2692877: Add Search API support