@@ -50,18 +50,21 @@ public function getQuery()
5050
5151 $ query = new BoolQuery ();
5252
53- if (present ($ this ->params ->queryString )) {
54- $ terms = explode (' ' , $ this ->params ->queryString );
53+ $ queryString = $ this ->params ->queryString ;
54+ if (present ($ queryString )) {
55+ // force exclusion even in `or` query
56+ $ queryString = preg_replace ('/(^| )-/ ' , ' +- ' , $ queryString );
57+ $ terms = explode (' ' , $ queryString );
5558
5659 // the subscoping is not necessary but prevents unintentional accidents when combining other matchers
5760 $ query ->must (
5861 (new BoolQuery ())
5962 // results must contain at least one of the terms and boosted by containing all of them,
6063 // or match the id of the beatmapset.
6164 ->shouldMatch (1 )
62- ->should (['term ' => ['_id ' => ['value ' => $ this -> params -> queryString , 'boost ' => 100 ]]])
63- ->should (QueryHelper::queryString ($ this -> params -> queryString , $ partialMatchFields , 'or ' , 1 / count ($ terms )))
64- ->should (QueryHelper::queryString ($ this -> params -> queryString , [], 'and ' ))
65+ ->should (['term ' => ['_id ' => ['value ' => $ queryString , 'boost ' => 100 ]]])
66+ ->should (QueryHelper::queryString ($ queryString , $ partialMatchFields , 'or ' , 1 / count ($ terms )))
67+ ->should (QueryHelper::queryString ($ queryString , [], 'and ' ))
6568 );
6669 }
6770
0 commit comments