From 07889abdc92ce2e4696fd46b4a2a3bfb8c26ed29 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 29 Feb 2020 22:24:32 +0100 Subject: [PATCH] Do not break when searching for slashes Resolves: https://github.com/cweiske/phinde/issues/36 --- src/phinde/Elasticsearch.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/phinde/Elasticsearch.php b/src/phinde/Elasticsearch.php index 5ca2180..fd60f95 100644 --- a/src/phinde/Elasticsearch.php +++ b/src/phinde/Elasticsearch.php @@ -122,6 +122,11 @@ class Elasticsearch ); } + if (strpos($query, '/') !== false && strpos($query, '"') === false) { + //add quotes when there is a slash and no quotes + // https://stackoverflow.com/questions/31963643/escaping-forward-slashes-in-elasticsearch + $query = '"' . $query . '"'; + } $qMust[] = array( 'query_string' => array( 'default_field' => '_all', -- 2.30.2