- 🇺🇸United States cboyden
@DamienMcKenna I think I have this working. You need to add the fields to the index; you do not need to add relationships to the view.
- Create the search index.
- Add your taxonomy fields to the index. In the selector, use the Add button for the top-level item, don't expand the sub-items. Use the data type Integer. If you also need to put the term names into the fulltext index or something, then you would add this field again, expand the sub-items, and use the Add button for the Name sub-item.
- Create the view using your search index.
- Add the filter. Choose "Vocab Name" as the filter, not any sub-items such as "Vocab Name > Taxonomy Term > Name"
- You should now have the option to choose Dropdown or Autocomplete.
Screenshot of adding the term to the index:
Screenshot of which filter to add:
- Status changed to Needs work
over 1 year ago 6:53am 22 August 2023 - 🇷🇴Romania SilviuChingaru
I also think that, if you have the NID, you could and should be able to relate to original node, and not to have to add all needed fields to the index. Is contra productive: why use more resursces when you already have the data in Drupal database?!
And from another perspective, you only care about texts in searches, why have to add images, for example, or other elements like buy it now form from commerce to index?
It could be implemented in Search API query plugin, quite like original views, if you have an relation, a secondary query could be made to Drupal's db on nids obtained from search index to relate all needed fields.
This way you could use the full potential of Drupal views on search results. - 🇺🇸United States DamienMcKenna NH, USA
Here's the expected scenario:
- Create an index for content (nodes).
- Add a taxonomy term reference field to the index, e.g. "field_tags", as an integer field.
- Create a view of the index.
- Add a relationship to the view for the tags: "Taxonomy term referenced from Tags"
- Open the "Add filter criteria" dialog.
- Expected results: a list of all fields of the Tags vocabulary are shown alongside all of the content fields.
- Actual results: no fields from the Tags vocabulary are shown.
- 🇦🇹Austria drunken monkey Vienna, Austria
@damienmckenna: I think you don’t completely understand the way Search API works. In the Search API, you can only filter on (and sort by, search through, etc.) fields that you have explicitly added to the index. When you index just
field_tags
, then that integer entity ID is what’s indexed on the server, and only this can be used for filtering/sorting/…. If you want to be able to add filters for any of the taxonomy term fields, you will have to add them to the search index first, as @cboyden explained in #12.
The relationships in Views are purely used for the “Fields” of the view, they don’t influence the available filters or sorts at all.