From 7d80a74d23da5b4198a33bb682ef51f052acb7c1 Mon Sep 17 00:00:00 2001 From: gibert Date: Fri, 31 May 2024 15:01:24 +0200 Subject: [PATCH] =?UTF-8?q?[bug]=20il=20faut=20=C3=A9chapper=20le=20OR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theses/builder/SearchQueryBuilder.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/abes/thesesapirecherche/theses/builder/SearchQueryBuilder.java b/src/main/java/fr/abes/thesesapirecherche/theses/builder/SearchQueryBuilder.java index a5c8421..97441ca 100644 --- a/src/main/java/fr/abes/thesesapirecherche/theses/builder/SearchQueryBuilder.java +++ b/src/main/java/fr/abes/thesesapirecherche/theses/builder/SearchQueryBuilder.java @@ -108,6 +108,7 @@ private String replaceSpacesOutsideQuotes(String input) { boolean insideQuotes = false; boolean insideBrackets = false; + for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); @@ -120,11 +121,22 @@ private String replaceSpacesOutsideQuotes(String input) { } else if (c == ']') { insideBrackets = false; result.append(c); - } else if (c == ' ' && !insideQuotes && !insideBrackets) { - result.append(" AND "); + } + else if (c == ' ') { + if (i + 2 < input.length() && input.charAt(i + 1) == 'O'&& input.charAt(i + 2) == 'R') { + + result.append(" OR "); + i+= 3; + } else if (!insideQuotes && !insideBrackets) { + result.append(" AND "); + } else { + result.append(c); + } } else { result.append(c); + } + } return result.toString();