Kirby search gives incomplete search result


I must say I already asked for help to set up the search results some months ago, but then the project got delayed and only now I am back to it.

I am testing the search function I implemented, and noticed it only works if you put in the search bar words that are part of the title of a page. What I’d like to implement, is to have the search function to scan the whole page and give back results based on all the fields part of a page.

To do that, I took out the second argument in the search function, eg


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


$artworks = $artworks->search($query);

but still no luck. I got no result back, and var_dump shows that as well.

Here the relevant portion of the search controller.

//++ collection
$collection = $site->children()->findBy('template', 'collection');

//++ artworks
$artworks = $collection->children()->findBy('intendedTemplate', 'artworks')->children()->visible();

//++ search
// return all children if nothing is selected
$query = get('q');

if($query) {
  $artworks = $artworks->search($query);

$artworks = $artworks->paginate(20);
$pagination = $artworks->pagination();

How to go on this?

Thanks, af

May I asked what your setup is? Is search a separate page with its own controller and template?

If you don’t pass any arguments, all fields are searched. I thought we got it working back then in the other thread?

Search is its own page w/ controller and template, but I setup also filter-by-tag in the same page—I don’t think it should interfere though.

In the other thread I was still using

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

so then it was just looking for those two fields, right?

Now I set it to

$artworks = $artworks->search($query);

but it only work for the title field.

Can I provide more informations?

That is strange. The native search method searches through all fields. You can test this in a starterkit like this:

In your home.php template, put this code:

$query = get('q');
$results = $site->index()->search($query);

Then call your homepage with the q parameter, e.g. like this:

Result should be:

Children Object
    [0] => projects/project-b
    [1] => projects/project-d

(where the year is stored in the year field, not title or text)

Question: if you call your search page without any parameter, what result do you get?

Your test worked like a charm indeed.

If I don’t search for some value, I simply get all the results—all the children of that page.

My kirby is updated to the latest version. I’ll take another peek at it, to see if I have missed something.

Can you give me an example of a search word that does not give you any results? And which pages that search word should reveal as a result and why? I.e. where the information is in your content file and in what sort of context?


Current folder structure:



Title: Artwork #12


Text: blabaha


Author: Edoardo Belli


Size: 33 x 24 cm


T: Arte astratta


Year: 2012


Bio: ALKAlakalaklakalakalakalaka


Location: XXXXXX


    label: Titolo
    type:  text
    label: Autore
    type: select
    options: query
      page: ../../autore
      fetch: children
      value: '{{title}}'
    label: Anno
    type: text
    width: 1/2
    label: Dimensioni
    type: text
    width: 1/2
    label: Tecnica
    type: tags
    label: Luogo
    type: select
    options: query
      page: luoghi
      fetch: grandchildren
      value: '{{title}}'

I can look up for 2012, Arta Astratta, Edoardo and get no result back. If I type Artwork I get all the list of pages containing Artwork in their title.

Is that site online somewhere?

Yes, this the search page →

github repo →

The repo still has the restriction to the title and text fields, are you sure you have changed the online version? I can’t make tests with the repo cause no content.

I blame having a fever for the fact that I thought I took out the second value after $query in here

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

as I did in fact, but on the wrong and very similar controller.php.

ty! working now!