Search method. Question?

Hi,

I would like a confirmation concerning the search method.

In the documentation, I see this example:

// search for full words only
$results = $pages->search('my awesome->search', ['words' => true, 'minlength' => 4]);

Does this mean that the search method searches on the exact word sequence (“word1 and word2 and word3”) and that each word must be at least 4 characters long?

Or does it works if i had this text: “Lorem ipsum word1. Blab bla word2 bla bla. word3 anyway.”?

minLength refers to the length of the complete search string.
words means, that Kirby only searches for full-word matches, not for parts of the each search string.

But keep in mind that Kirby search does treat each words in the search string as separate queries (OR), so you won’t get search results that contains the complete query string only.

So if a page contains my and another awesome, both will be returned.

So if I search “awesome” and ['words' => false] Kirby return a page where there are “some”? :thinking:

Yep

Thanks Sonja, I now understand better how method search works :slight_smile:

Maybe you are interested in this plugin: Better Search | Kirby CMS

1 Like