How to index user entity data from entity reference fields?

Created on 26 June 2020, over 4 years ago
Updated 9 March 2023, almost 2 years ago

First, thanks to all the devs who put time into this module. The world is a better place now. :)

I have added entity reference fields to my users. These fields store data like office locations and phone numbers.

How do I make that data searchable?

Specifically, I want to search for data in the entity reference, but return the user the reference is for. So if I search for a phone number, the user who has that phone number in an entity reference should be returned. Not the content entity the phone number is stored in. (Long story short, this was the best way I could relate phones with offices and let users have multiple listings... Didn't use paragraphs for reasons to detailed to go into here. Not pretty, but it works.)

I've configured a Search API Page to search only Users. When I search for a name, it finds users just fine. If I search for a phone number, or office, it doesn't.

See the attached screenshot for the page settings.

On admin/config/search/search-api/index/reagan4_elasticsearch_sapi_index/fields, I have added the reference fields under the User section.

On the processors page, I've selected "Reverse entity references".

The closest documentation page I found to an answer is this: https://www.drupal.org/docs/8/modules/search-api/developer-documentation... β†’ Do I really need to add a custom module to get entity references indexed?

My general web searches didn't find many clues.

Thanks in advance!

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States jerrac

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 jerrac

    Well, lovely, the first result in my search was something I posted myself....

    Anyway, I was trying to figure out why results were not showing up when I searched for terms in referenced entities, even though I had set the fields up correctly.

    Long story short, adding a field to an index, doesn't actually enable it on a search page. You also need to update the "Searched Fields" box in the search api page settings.

  • πŸ‡¨πŸ‡³China fishfree

    @jerrac Thank you for your sharing. What do you mean by update the "Searched Fields" box in the search api page settings? Could you also give the page path please?

  • πŸ‡ΊπŸ‡ΈUnited States xenophyle

    I think they mean in the fulltext search filter configuration in a view

Production build 0.71.5 2024