getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Site search: Parameters seem to be broken #4641

Closed FynnZW closed 2 years ago

FynnZW commented 2 years ago

The additional site search parameters are not behaving as expected. This is working correctly:

// controllers/search.php
return function ($site) {
  $query   = get('q');

  $results = $site->search($query, 'text|title');

  return [
    'query'   => $query,
    'results' => $results
  ];
};

However, this is not:

minlength

  $results = $site->search($query, [
    "fields" => ["text", "title"],
    "minlength" => 5,
  ]);

--> If the search query is shorter than the minlength, all pages get returned (instead of zero)

stopwords

  $results = $site->search($query, [
    "fields" => ["text", "title"],
    "stopwords" => ["und", "and"]
  ]);

--> stopwords are not being ignored, result does not change

I have not tested the other parameters.

Expected behavior
minlength > query length should return zero results. stopwords should be ignored during search

Kirby Version
3.7.5

afbora commented 2 years ago