Do not break when searching for slashes
authorChristian Weiske <cweiske@cweiske.de>
Sat, 29 Feb 2020 21:24:32 +0000 (22:24 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 29 Feb 2020 21:24:32 +0000 (22:24 +0100)
Resolves: https://github.com/cweiske/phinde/issues/36

src/phinde/Elasticsearch.php

index 5ca2180..fd60f95 100644 (file)
@@ -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',