Favor exact title matches in site search
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #2558663. -->
Reported by: [drumm](https://www.drupal.org/user/3064)
>>>
<h3>schema.xml change:</h3>
<pre>- <field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/><br>+ <!-- Drupal.org change: omitNorms true → false. Favor more-exact title matches. See https://www.drupal.org/node/2558663 --><br>+ <field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="false"/></pre><h3>Notes from <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupalorg/-/work_items/658048" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupalorg/-/work_items/658048</a></span></h3>
<p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupalorg/-/work_items/658048" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupalorg/-/work_items/658048</a></span></p>
<blockquote><p>we chose to set omitNorms="true" in for the title field in schema.xml. If we set this to false, a short title that matched exactly would get a much bigger boost. Perhaps it would be worth comparing the effect of setting this to normed - the only normed field currently is the body.</p></blockquote>
<p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupalorg/-/work_items/658048" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupalorg/-/work_items/658048</a></span></p>
<blockquote><p>if it's possible to say "if the search term is an exact match of a project short name, shoot it to the top of the list" that would certainly help.</p></blockquote>
<p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupalorg/-/work_items/658048" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupalorg/-/work_items/658048</a></span></p>
<blockquote><p>The pattern here seems to be "if it's an exact title match, make it the first thing in the list."</p></blockquote>
<p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/drupalorg/-/work_items/658048" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/drupalorg/-/work_items/658048</a></span></p>
<blockquote><p><strong>We need to make exact match score higher than contains. Exact match in Solr is a bit of a deeper dive. Accounting to the <a href="https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_make_exact-case_matches_score_higher">Solr wiki</a>, we need to:</strong></p>
<blockquote><p>index the content twice, using different fields with different fieldTypes (and different analyzers associated with those fieldTypes). One analyzer will contain a lowercase filter for case-insensitive matches, and one will preserve case for exact-case matches.</p></blockquote>
<p>Ironically, this would help with searches for terms like "apachesolr"—we might actually get back the apachesolr module with that search.</p>
<p>We could take this a step further and bias—I know I said we had to be careful with this—a project shortname field to be more important than even title. (That might cause some weird outcomes though.)</p></blockquote>
issue
GitLab AI Context
Project: project/drupalorg
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/drupalorg/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/drupalorg
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD