-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from tulibraries/BL-1855-solr-exact-searches
BL-1855 solr exact searches
- Loading branch information
Showing
9 changed files
with
438 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,3 +320,6 @@ | |
.before(["c", "b"]) | ||
end | ||
end | ||
|
||
|
||
# body = JSON.parse(phrase_query_results.response[:body])["response"]["numFound"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# frozen_string_literal: true | ||
require "spec_helper" | ||
|
||
RSpec.describe "Searches with quotes in the terms" do | ||
before do | ||
end | ||
|
||
let(:solr) { RSolr.connect(url: ENV["SOLR_URL"]) } | ||
let(:term) { "" } | ||
let(:quoted_term) { "\"#{term}\""} | ||
let(:solr_path) { "search" } | ||
let(:extra_params) { {} } | ||
let(:num_found_quoted) { | ||
results = solr.get(solr_path, params: { q: quoted_term } | ||
.merge(extra_params)) | ||
results["response"]["numFound"] | ||
} | ||
let(:num_found_not_quoted) { | ||
results = solr.get("search", params: { q: term } | ||
.merge(extra_params)) | ||
results["response"]["numFound"] | ||
} | ||
|
||
|
||
context "quoted queries with more than one term" do | ||
let(:term) { "book readers"} | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "quoted queries with one term" do | ||
let(:term) { "readers" } | ||
# In the application with override this path dynamically. | ||
let(:solr_path) { "single_quoted_search" } | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
|
||
context "title quoted query with one term" do | ||
let(:term) { "readers" } | ||
let(:extra_params) { { qf: "${title_qf}", pf: "${title_pf}" }} | ||
# In the application with override this path dynamically. | ||
let(:solr_path) { "single_quoted_search" } | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "title quoted query with multiple terms" do | ||
let(:term) { "Book readers" } | ||
let(:extra_params) { { qf: "${title_qf}", pf: "${title_pf}" }} | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "subject quoted query with one term" do | ||
let(:term) { "chemically" } | ||
let(:extra_params) { { qf: "${subject_qf}", pf: "${subject_pf}" }} | ||
# In the application with override this path dynamically. | ||
let(:solr_path) { "single_quoted_search" } | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "subject quoted query with multiple terms" do | ||
let(:term) { "ancient history" } | ||
let(:extra_params) { { qf: "${subject_qf}", pf: "${subject_pf}" }} | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "author quoted query with one term" do | ||
# This test doesn't work with all names in this test set. | ||
let(:term) { "William" } | ||
let(:solr_path) { "single_quoted_search" } | ||
let(:extra_params) { { qf: "${author_qf}", pf: "${author_pf}" }} | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
context "author quoted query with multiple terms" do | ||
let(:term) { "William Shakespeare" } | ||
let(:extra_params) { { qf: "${author_qf}", pf: "${author_pf}" }} | ||
|
||
it "quoted query to have less results than regular query" do | ||
expect(num_found_quoted).to be < num_found_not_quoted | ||
end | ||
end | ||
|
||
end | ||
|
||
|