1

I have a website I am working on that has a TON of content. The client has noticed that when searching for titles in the site search, it seems to prioritize the body content over the title.

So I changed the search index for titles to be fulltext with a boost of 13. With the rendered output set to a boost of 1. Then I reindexed and that didn't fix it. I did a full rebuild of tracking information. Same problem.

I found this article: https://medium.com/@easternstandard/how-to-configure-drupal-8-text-search-to-return-better-more-intuitive-search-results-fe0a78136ad7

And followed the instructions there (pretty much what I had already done) and reindexed. Same issue.

An example of this is that we have an article about the response to covid where the phrase "response to covid" is part of the title. When I search for that phrase I do not see it in any of the first-page search results. It is set to show 20 items. In fact, the article in question doesn't come up until result number 39. None of the prior articles seem to have covid in the title at all. Even searching with quotations makes no difference.

This is currently using the database search/index. I am tempted to implement Solr. But that is a whole-nother ball of wax and I am on a deadline right now.

We are running Drupal 8.9.9 and the Search API 8.x-1.18.

What can I do differently to make it value the title over the rendered content?

3
  • 2
    One thing that may be helpful is to (on a test environment) display the search relevance score with your search results, for each piece of content, i.e. add it as a display field. Then you can play around with the boost settings and see how the changes affect the content's score. You should also check that your view is sorting by "Search: Relevance (desc)" – sonfd Jan 22 at 18:13
  • That's an interesting idea. Thanks. – Patrick Jan 22 at 18:31
  • @sonfd , your answer pointed me to the problem. We were sorting by relevance. But it was ascending instead of descending. Setting it to descending solved it. Can you add this as an answer so that I can give you credit for it? – Patrick Jan 22 at 20:41
2

Make sure your view's topmost sort is set to "Search: Relevance (desc)" to sort your results from most relevant to least relevant.


Add the "Search: Relevance" field to your displayed fields while configuring your index. You'll see each result's relevance score inline - it's super helpful to see the impact of your various index adjustments. E.g. How much does boosting the title field by 8.0 affect a result's total score.

1
  • Thank you again. – Patrick Jan 22 at 22:25

Your Answer

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

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