Explorar o código

fix: elasticsearch partial match (#1882)

Improved full text search in elastic provider
kaziu687 %!s(int64=5) %!d(string=hai) anos
pai
achega
66e725f426
Modificáronse 1 ficheiros con 20 adicións e 2 borrados
  1. 20 2
      server/modules/search/elasticsearch/engine.js

+ 20 - 2
server/modules/search/elasticsearch/engine.js

@@ -92,8 +92,26 @@ module.exports = {
         index: this.config.indexName,
         body: {
           query: {
-            simple_query_string: {
-              query: q
+            bool: {
+              filter: [
+                {
+                  bool: {
+                    should: [
+                      {
+                        simple_query_string: {
+                          query: q
+                        }
+                      },
+                      {
+                        query_string: {
+                          query: "*" + q + "*"
+                        }
+                      }
+                    ],
+                    minimum_should_match: 1
+                  }
+                }
+              ]
             }
           },
           from: 0,