Skip to content

Commit 4814b9c

Browse files
committed
Switch to 'simple_query_string' search type by default.
1 parent 6b9c654 commit 4814b9c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This driver has a simple configuration, requiring you to only publish the config
99

1010
Note that this driver uses a separate index for each model type as elasticsearch mapping types have been deprecated in elasticsearch 6.0 and will be removed in 8.0, for more information see https://bit.ly/2TZVZvq.
1111

12+
By default, the driver uses the `simple_query_string' full text parser with `and` set as the default operator. More information on the functionality & syntax of this query format can be found (here)[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html].
13+
1214
Based on the original work of [ErickTamayo](https://github.com/ErickTamayo/laravel-scout-elastic). **Requires Scout ^5.0, ^6.0, or ^7.0, Laravel >=5.4, PHP >=7.0**
1315

1416
## Contents

src/ElasticsearchEngine.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ protected function performSearch(Builder $builder, array $options = [])
144144
'body' => [
145145
'query' => [
146146
'bool' => [
147-
'must' => [['query_string' => [ 'query' => "*{$builder->query}*"]]]
147+
'must' => [
148+
["simple_query_string" => [
149+
"query" => $builder->query,
150+
"default_operator" => "and"
151+
]]
152+
]
148153
]
149154
]
150155
]

tests/ElasticsearchEngineTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public function test_search_sends_correct_parameters_to_elasticsearch()
6262
'query' => [
6363
'bool' => [
6464
'must' => [
65-
['query_string' => ['query' => '*zonda*']],
65+
['simple_query_string' => [
66+
'query' => 'zonda',
67+
"default_operator" => "and"]],
6668
['match_phrase' => ['foo' => 1]],
6769
['terms' => ['bar' => [1, 3]]],
6870
]

0 commit comments

Comments
 (0)