Views relationships to source entities

Created on 1 October 2021, about 3 years ago
Updated 17 January 2023, almost 2 years ago

It's unclear how you're supposed to build a relationship to the original entity so that you can e.g. add the index to an existing node in order to add an exposed fulltext filter field. I didn't see anything in the documentation about it.

Feature request
Status

Postponed: needs info

Version

1.0

Component

Views integration

Created by

🇺🇸United States DamienMcKenna NH, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸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.

    1. Create the search index.
    2. 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.
    3. Create the view using your search index.
    4. Add the filter. Choose "Vocab Name" as the filter, not any sub-items such as "Vocab Name > Taxonomy Term > Name"
    5. 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
  • 🇷🇴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.

Production build 0.71.5 2024