I have a site-wide search page that's powered by Search API and Search API Solr. It returns results straight from an index that contains content from various entity types (files, nodes, taxonomies, etc.). Among the things rendered in the search result is a description, a short blurb of text from the content.

The problem I have is that this blurb isn't just one field. The different entities use different fields as their description field. They have different required states, so some of them are guaranteed to have values, while others can be blank. Some entities don't even have the field at all.

How do I index all entities to have a single "description" field that could come from one of many possible fields?

For example:

  • field_page_description (Article content type has this)
  • field_something_description (Basic Page content type has this)
  • field_another_description (Another Page file type has this)

I want to check field_page_description first if it exists and has a value. If it does, index that. If it doesn't, repeat the process on the next field. If all of the fields are empty or non-existent, the index value indexed shall be blank. In the end, I'd have a single field in the index whose value comes from any one of the three fields.

How should I go about this?

  • Try Global: Combine fields filter. You need to have the Fields added to the View that you want searched through this filter. – prkos Jun 27 '19 at 11:21
  • @prkos That's what I was trying to avoid. I have more than a dozen entity types and they have different "description" fields. I'm trying to avoid adding a dozen or so fields into the view to conditionally filter and render. I'd like to combine them at the index level so that the View only sees one description field. – Joseph Jun 27 '19 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.