Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not override query on collection pages when fulltext search is applied #2557

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/portal/src/components/search/SearchInterface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@

if (this.advancedSearchQueryCount > 0) {
if (this.hasFulltextQa) {
// override query overrides already here to prevent full-text search breaking
if (this.overrideParams.query) {
params.query = this.overrideParams.query;
delete this.overrideParams.query;
}

// If there are any advanced search full-text rules, then
// these are promoted to the primary query, and any other query
// (from the simple search bar) is demoted to a qf, fielded to
Expand Down
2 changes: 2 additions & 0 deletions packages/portal/src/pages/collections/_type/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
if (this.entity) {
const entityQuery = getEntityQuery([this.entity.id].concat(this.entity.sameAs || []));
overrideParams.qf = [entityQuery];

if (!this.$route.query.query) {
overrideParams.query = entityQuery; // Triggering best bets.
}
Expand Down Expand Up @@ -303,6 +304,7 @@
return labelledMoreInfo;
}
},

methods: {
handleEntityRelatedCollectionsFetched(relatedCollections) {
this.relatedCollections = relatedCollections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,41 @@ describe('components/search/SearchInterface', () => {

expect(wrapper.vm.apiParams).toEqual(expected);
});

describe('and a query override', () => {
it('is promoted into query, moving the query override to qf', () => {
const queryOverride = 'skos_concept:"http://data.europeana.eu/concept/001"';
const $route = {
query: {
qa: [
'fulltext:europe',
'NOT fulltext:united'
]
}
};
const expected = {
page: 1,
profile: 'minimal,hits',
query: 'fulltext:europe AND NOT fulltext:united',
qf: [queryOverride, 'contentTier:(1 OR 2 OR 3 OR 4)'],
rows: 24
};

const wrapper = factory({
propsData: {
overrideParams: {
query: queryOverride
}
},
mocks: {
$route
}
});
wrapper.vm.deriveApiParams();

expect(wrapper.vm.apiParams).toEqual(expected);
});
});
});
});

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/docker/nightwatch/support/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const pages = {
'gallery foyer page': `${url}/en/galleries`,
'home page': `${url}/en`,
'Newspapers theme search page': `${url}/en/search?qf=collection%3Anewspaper`,
'newspaper entity page': `${url}/en/collections/topic/18-newspaper`,
'immersive story page': `${url}/en/stories/melitta-bentz-the-woman-who-invented-the-coffee-filter`,
'item page with a IIIF Image': `${url}/en/item/9200357/BibliographicResource_3000095247457`,
'item page with a IIIF Presentation': `${url}/en/item/9200301/BibliographicResource_3000126341277`,
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/features/search/advanced.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ Feature: Advanced search
And I wait for an `item preview`
Then I see a `highlighted search term` with the text "First World War"
And I am on an accessible page

Scenario: Full-text search on a collection page shows hit highlights
When I open the `newspaper entity page`
And I click the `search list view toggle icon`
When I click the `toggle advanced search button`
And I enter "berlin" in the `advanced search query builder: term control`
And I click the `advanced search query builder: field control`
And I click the `advanced search query builder: fulltext field option`
And I click the `advanced search query builder: modifier control`
And I click the `advanced search query builder: exact modifier option`
And I wait for an `item preview`
Then I see a `highlighted search term` with the text "Berlin"
And I am on an accessible page
Loading