Skip to content

Commit ec11e09

Browse files
Merge pull request #569 from mlibrary/LIBSEARCH-1139-the-contents-of-the-keyword-field-in-all-advanced-searches-are-not-being-wrapped-in-parentheses
[LIBSEARCH-1139] The contents of the 'Keyword' field in all advanced searches are not being wrapped in parentheses
2 parents 85fdf09 + 1fd0c5d commit ec11e09

File tree

1 file changed

+7
-3
lines changed
  • src/modules/advanced/components/AdvancedSearchForm

1 file changed

+7
-3
lines changed

src/modules/advanced/components/AdvancedSearchForm/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ const AdvancedSearchForm = ({ datastore }) => {
4242

4343
/*
4444
* Build the query
45-
* example: 'title:parrots AND author:charles'
45+
* example: '(evolution) AND title:(parrots) AND author:(charles)'
4646
*/
4747
const query = fieldedSearches
4848
.reduce((memo, fieldedSearch) => {
49-
if (fieldedSearch.query.length) {
49+
const { field, query: queryValue } = fieldedSearch;
50+
if (queryValue.length) {
5051
if (memo.length > 0) {
5152
memo.push(booleanTypes[fieldedSearch.booleanType]);
5253
}
53-
const input = fieldedSearch.field === 'keyword' ? fieldedSearch.query : `${fieldedSearch.field}:(${fieldedSearch.query})`;
54+
let input = `(${queryValue})`;
55+
if (field !== 'keyword') {
56+
input = `${field}:${input}`;
57+
}
5458
memo.push(input);
5559
}
5660

0 commit comments

Comments
 (0)