5

I'm using Search API with a database backend and Views to build the search results page. More specifically, I'm using fields in Views. When selecting fields, I see two options for example:

  • Title
  • Title (indexed field)

When using this field, I get the same result. So I'm wondering why might I use the indexed version over the regular?

enter image description here

5
  • Simple: Title provided for Views from Entity. Title (indexed field) provided for Views from SOLR. For example: If you use Title as filter - Drupal will use it by own filter handlers. So first, it will request data from SOLR (for example 100 found rows), then Views make filter on found rows, reducing it to 10 found rows - as you see - it's not good for performance. Better is using Title (indexed field), that will request only 10 records from SOLR server. Against, title will more preferred for outputs, than indexed fields (for some cases).
    – Nikit
    Commented Apr 28, 2021 at 1:04
  • 1
    TLDR: Indexed field grabs the field from the search API index, rather than the Drupal database. So Indexed field probably the one you want.
    – 100pic
    Commented Apr 28, 2021 at 6:14
  • Thanks for both of your answers. Makes perfect sense.
    – chrisck
    Commented Apr 28, 2021 at 7:57
  • @Nikit That seems an answer.
    – avpaderno
    Commented Apr 29, 2021 at 21:02
  • @kiamlaluno ok, I have copy to answers.
    – Nikit
    Commented May 6, 2021 at 1:20

1 Answer 1

1

Simple:

  • Title provided for Views from Content entity.
  • Title (indexed field) provided for Views from SOLR.

For example: You have 1000 contents, and you want to show 10 of these, titles of that starts "Z" letter.

If you use Title as filter - Drupal will use it by Views handlers, so:

  1. It will request data from SOLR server, in our case - all 1000 items.
  2. The Views filter on found items, reducing it to the required 10 "Z" contents.

As you see - it's not good for performance. Better is using Title (indexed field)as Views filter, that will request only required 10 records from SOLR server.

p.s. Against it, title will prefer for Views output than indexed field (for some cases).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.