Once again: Find something in a structured field

I want to search/filter a list of Artists stored in a Structure Field.

Here’s my blueprint:

              artists:
                label: 
                  en: Archived Artists
                  de: Archiv Artists
                type: structure
                fields:
                  firstname:
                    label: 
                      en: First Name
                      de: Vorname
                    type: text
                  lastname:
                    label: 
                      en: Last Name
                      de: Nachname
                    type: text
                  category:
                    label: 
                      en: Category
                      de: Bereich
                    type: select
                    options:
                      visual: 
                        en: Visual Arts and Media
                        de: Visuelle Kunst und Medien
                      literature: 
                        en: Literature / Language
                        de: Literatur / Sprache
                      performingarts: 
                        en: Performing Arts
                        de: Darstellende Kunst
                      music: 
                        en: Music
                        de: Musik
                      curating: 
                        en: Curating
                        de: Kuratieren
                      coordination: 
                        en: Arts Coordination
                        de: Kunstkoordination
                      group:
                        en: Group Work
                        de: Gruppenstipendium
                  website:
                    label: 
                      en: Website
                      de: Webseite
                    type: url
                  residence:
                    label: 
                      en: Year
                      de: Jahr
                    type: number

Here’s my controller:

return function ($kirby, $site, $pages, $page) {
	# get url parameters
	$query = get('q');

	# get archived artists
	$archive = $page->artists()->toStructure();

	if ( $query ) :
		$archive = $archive->filterBy('firstname', '*=', $query)->filterBy('lastname', '*=', $query);
	endif;

	return array(
		'archive' => $archive,
		'query' => $query
	);

};

Looping over the $archive in the Template with no results for a query.
Any Ideas on what’s wrong?

Your filter means that you first filter by firstname, and those again by lastname, so unless your query term is, for example, James, and you have an artist called James James, this will yield no results.

What you want to do is search, and you can us the search() method on the structure collection just like you can on pages.

For examples see $pages->search()

I started trying the search method but also without luck.
The filter should work if just use one? Because then I also get no result.

With both of the following cases I just get an empty Structure Object:

Kirby\Cms\Structure Object
(
)

		$archive = $archive->filterBy('lastname', '*=', $query);
		dump($archive);

		$archive = $archive->search($query);
		dump($archive);

Works perfectly for me in a Starterkit (where we have a structure field in the about page), example:

$result = page('about')->social()->toStructure()->search('Insta');
dump($result);

Where is the query string coming from, a form, a link? "hat do you if you dump($query);

Okay that’s weird. The query string comes from a form and ?q=xyz returns xyz in the dump($query)

Update with fresh eyes - yes it works! User error, haha.

Thank you @texnixe