# Spaces in searched words

**URL:** <https://forum.getkirby.com/t/spaces-in-searched-words/26940>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 3, 2022, 3:57pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940 "2022-11-03T15:57:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ete.cool](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@ete.cool](https://forum.getkirby.com/u/ete.cool)\
**Post date:** [November 3, 2022, 3:57pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/1 "2022-11-03T15:57:03Z")

</div>

Hi i made search page with kirby’s search option.  
but when I search word with space, they show even if only one of the two words is included…  
It is very uncomfortable because when I search “jan blablabla” then they show "jan blablal"and “jannik”…  
I found kirby’s search is using “or” option and change to "and"is not that easy…  
then is there anyway to make select category before searching?  
I really want to try algolia but I even don’t know where to start…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 3, 2022, 4:02pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/2 "2022-11-03T16:02:48Z")

</div>

Check out this plugin: [Better Search | Kirby CMS](https://getkirby.com/plugins/bvdputte/bettersearch)

There’s also an Algolia plugin in the [getkirby.com](http://getkirby.com) repo: [getkirby.com/site/plugins/search at main · getkirby/getkirby.com · GitHub](https://github.com/getkirby/getkirby.com/tree/main/site/plugins/search)

---

<div class="post-metadata">

**Author:** ![ete.cool](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@ete.cool](https://forum.getkirby.com/u/ete.cool)\
**Post date:** [November 3, 2022, 4:16pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/3 "2022-11-03T16:16:58Z")

</div>

Thank you very much!  
I upload that plugin and I don’t know where to put this…

```auto
$pages->bettersearch($string, $options)

```

my code is… 🙂

```auto
<?php

return function ($site) {

  $query = get('q');
  $results = page('home')->search($query, 'author|bookTitle|year|ISBN|category|librarian');
  $results = $results->paginate(300);

  return [
    'query' => $query,
    'results' => $results,
    'pagination' => $results->pagination()
  ];

};

```

I put them on results… It is not wokring…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 3, 2022, 4:25pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/4 "2022-11-03T16:25:41Z")

</div>

> [@ete.cool](#):
>
> ` $results = page('home')->search($query, 'author|bookTitle|year|ISBN|category|librarian');`

Instead of this line, use

```auto
$results = page('home')->index()->betterSearch($query, 'author|bookTitle|year|ISBN|category|librarian');

```

---

<div class="post-metadata">

**Author:** ![ete.cool](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@ete.cool](https://forum.getkirby.com/u/ete.cool)\
**Post date:** [November 3, 2022, 4:29pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/5 "2022-11-03T16:29:53Z")

</div>

thank you but then thay said “Call to a member function paginate() on null”…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 3, 2022, 4:36pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/6 "2022-11-03T16:36:09Z")

</div>

Ah, my mistake, the method name does not work with capital `S`, use `bettersearch` instead of `betterSearch`.

---

<div class="post-metadata">

**Author:** ![ete.cool](https://avatars.discourse-cdn.com/v4/letter/e/65b543/32.png) [@ete.cool](https://forum.getkirby.com/u/ete.cool)\
**Post date:** [November 3, 2022, 4:40pm UTC](https://forum.getkirby.com/t/spaces-in-searched-words/26940/7 "2022-11-03T16:40:08Z")

</div>

> [@texnixe](#):
>
> ```auto
> $results = page('home')->index()->betterSearch($query, 'author|bookTitle|year|ISBN|category|librarian');
> 
> ```

Oh!! super!! thank you very much!!! 😭😭😭😭
