Skip to content

Commit

Permalink
Filter out spaces and orphan "
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Mar 23, 2022
1 parent 7a512f0 commit 408aa9f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Searchkit/CustomESRequestSerializer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ export class CustomESRequestSerializer {
let qs = queryString
.trim()
.split(' ')
// filter out spaces and orphan "
.filter((word) => word !== '' && word !== '"')
// replace orphan "
.map((word) => {
if (
(word.startsWith('"') && word.endsWith('"')) ||
(!word.startsWith('"') && !word.endsWith('"'))
)
return word;
else {
return word.replace('"', '');
}
})
.map((s) => {
// fuzzy search only if not wildcard and no paranthesis
if (s.includes('*') || s.includes('"')) {
Expand All @@ -77,7 +90,6 @@ export class CustomESRequestSerializer {
}
})
.join(' ');
// console.debug('querystring qs', qs);
let simpleFields = [
'title^1.4',
'id',
Expand Down

0 comments on commit 408aa9f

Please sign in to comment.