Skip to content

Commit 2d58d19

Browse files
authored
Merge pull request #397 from MITLibraries/use-601
Adds about natural language search page and links
2 parents 7166438 + a4bcf66 commit 2d58d19

9 files changed

Lines changed: 66 additions & 5 deletions

File tree

app/controllers/static_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
class StaticController < ApplicationController
44
def style_guide; end
55

6+
def about_natural_language_search; end
7+
68
def boolpref
79
if params[:boolean_type].present?
810
cookies[:boolean_type] = params[:boolean_type]

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def timdex_source_defaults
1414
end
1515

1616
def index_page_title
17-
ENV.fetch('PLATFORM_NAME', nil) ? "Search #{ENV.fetch('PLATFORM_NAME')} | MIT Libraries" : 'Search | MIT Libraries'
17+
ENV.fetch('PLATFORM_NAME', nil) ? ENV.fetch('PLATFORM_NAME') : 'Search | MIT Libraries'
1818
end
1919

2020
def results_page_title(query, character_limit = 50)

app/models/normalize_timdex_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NormalizeTimdexRecord
1111
'Research Databases' => ['Research Databases', 'https://libguides.mit.edu/az/databases'],
1212
'MIT Libraries Website' => ['Library Website', 'https://libraries.mit.edu/'],
1313
'MIT Alma' => ['MIT Libraries Catalog',
14-
"#{ENV.fetch('MIT_PRIMO_URL')}/discovery/search?vid=#{ENV.fetch('PRIMO_VID')}&lang=en"]
14+
"#{ENV.fetch('MIT_PRIMO_URL', nil)}/discovery/search?vid=#{ENV.fetch('PRIMO_VID', nil)}&lang=en"]
1515
}.freeze
1616

1717
def initialize(record, query)

app/views/search/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a href="https://libraries.mit.edu/search-advanced" data-matomo-click="Search, Advanced Search Engaged, Tab: {{getActiveTabName}}">Advanced search</a>
1414
<div class="semantic-search-toggle <%= @natural_language_search_optin ? 'toggled-on' : 'toggled-off' %>" data-controller="natural-language-search-toggle" data-matomo-seen="Semantic Search Toggle, Seen by user, Tab: {{getActiveTabName}}">
1515
<button type="button" aria-pressed="<%= @natural_language_search_optin %>" data-action="click->natural-language-search-toggle#toggle" data-matomo-click="Semantic Search Toggle, Toggle Clicked, Was: {{getToggleState}}">Natural language search</button>
16-
<a href="#" data-matomo-click="Semantic Search Toggle, Learn more Clicked, Tab: {{getActiveTabName}}">Learn more</a>
16+
<%= link_to "Learn more", about_natural_language_search_path, data: { matomo_click: "Semantic Search Toggle, Learn more Clicked, Tab: {{getActiveTabName}}" } %>
1717
</div>
1818
</div>
1919
</form>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<aside class="nls-alert">
22
<i class="fa-regular fa-circle-exclamation"></i>
3-
<p>Natural language search is not available for these results<a href="#">Learn more</a></p>
3+
<p>Natural language search is not available for these results <%= link_to "Learn more", about_natural_language_search_path, data: { turbo_frame: "_top" } %></p>
44
</aside>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<% content_for :title, "About Natural Language Search" %>
2+
3+
<div class="container">
4+
<h2>Opting in to Natural Language Search</h2>
5+
6+
<h3>What does turning on the Natural Language Search (NLS) do?</h3>
7+
8+
<p>By default, this search tool uses traditional keyword matching.</p>
9+
10+
<p>If you enable the Natural Language Search (NLS) option, the search tries to understand the meaning and intent behind your search terms, not just matching exact keywords.</p>
11+
12+
<p>For example, if you search for "climate change impacts," the NLS can find results about "global warming effects" or "environmental shifts"&mdash;even if those exact words don't appear together or at all in the source.</p>
13+
14+
<p>You can opt-in and out of the NLS to try both options to see which results are better for different types of queries. We'll remember your last choice to make it easier to continue where you left off.</p>
15+
16+
<h3>How can I tell you what I think about NLS?</h3>
17+
18+
<p><a href="https://libraries.mit.edu/use-feedback">Send us your feedback!</a> Sharing your experiences (good and bad) will help us understand how to make these search options work better.</p>
19+
<p>In our experience, NLS works well for:</p>
20+
<ul>
21+
<li>Natural language queries ("what causes ocean acidification?")</li>
22+
<li>Concept-based searches rather than exact phrases</li>
23+
<li>Exploratory research where related terms are valuable</li>
24+
</ul>
25+
26+
<p>Traditional keyword searching works well for:</p>
27+
<ul>
28+
<li>Specific item searches (i.e. pasting an article title or full citation into the search box)</li>
29+
</ul>
30+
31+
<p>Do you agree? <a href="https://libraries.mit.edu/use-feedback">Let us know what you think.</a></p>
32+
33+
<h3>Are there any limitations I should be aware of?</h3>
34+
35+
<p>This search tool (the default on the MIT Libraries homepage) searches across many MIT Libraries catalogs, indexes, and content sources and not all of these can be searched with NLS. You'll still get results from all sources - but we will revert to traditional keyword matching when NLS is not possible.</p>
36+
37+
<p>That means if you have enabled NLS, this is what you'll get on each tab:</p>
38+
<ul>
39+
<li>All tab (default): results listing "Articles, Books &amp; More" as a source use traditional keyword matching, all other results use NLS</li>
40+
<li>Articles/Books &amp; Media tabs: all results use traditional keyword matching</li>
41+
<li>All other tabs: all results use NLS</li>
42+
</ul>
43+
</div>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
get 'turnstile', to: 'turnstile#show', as: 'turnstile'
1616
post 'turnstile/verify', to: 'turnstile#verify', as: 'turnstile_verify'
1717
get 'style-guide', to: 'static#style_guide'
18+
get 'about-natural-language-search', to: 'static#about_natural_language_search'
1819

1920
get 'boolpref', to: 'static#boolpref'
2021
get 'natural_language_search_optin', to: 'static#natural_language_search_optin'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'test_helper'
2+
3+
class StaticControllerTest < ActionDispatch::IntegrationTest
4+
test 'about natural language search page returns success' do
5+
get about_natural_language_search_path
6+
7+
assert_response :success
8+
end
9+
10+
test 'style guide page returns success' do
11+
get style_guide_path
12+
13+
assert_response :success
14+
end
15+
end

test/helpers/application_helper_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ApplicationHelperTest < ActionView::TestCase
8181
ClimateControl.modify PLATFORM_NAME: 'GeoData' do
8282
query = { q: 'foo' }
8383
record = { 'title' => 'bar' }
84-
assert_equal 'Search GeoData | MIT Libraries', index_page_title
84+
assert_equal 'GeoData', index_page_title
8585
assert_equal 'foo | GeoData | MIT Libraries', results_page_title(query)
8686
assert_equal 'bar | GeoData | MIT Libraries', record_page_title(record)
8787
end

0 commit comments

Comments
 (0)