From 408aa9f75158d288564e3583f6f33d3399259577 Mon Sep 17 00:00:00 2001 From: ksuess Date: Wed, 23 Mar 2022 16:24:00 +0100 Subject: [PATCH] Filter out spaces and orphan " --- .../Searchkit/CustomESRequestSerializer.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Searchkit/CustomESRequestSerializer.jsx b/src/components/Searchkit/CustomESRequestSerializer.jsx index 24c150e3..657cd2d0 100644 --- a/src/components/Searchkit/CustomESRequestSerializer.jsx +++ b/src/components/Searchkit/CustomESRequestSerializer.jsx @@ -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('"')) { @@ -77,7 +90,6 @@ export class CustomESRequestSerializer { } }) .join(' '); - // console.debug('querystring qs', qs); let simpleFields = [ 'title^1.4', 'id',