I am using the Element API to search for entries that match a search query: either the title OR the excerpt should contain the query term. The entry is very simple and has these fields:
-title
-excerpt
-link
when I use this to only search in the title field it works:
$section_handle = ['item'];
$q = Craft::$app->request->getParam('query');
$criteria = [
'section' => $section_handle,
'search' => 'title:'.$q
];
So I thought I just add the excerpt field like this:
$criteria = [
'section' => $section_handle,
'search' => 'title:'.$q.' OR '.'excerpt:'.$q
];
but this did NOT work and I found out that it just won't search that excerpt field, this also does not work:
$criteria = [
'section' => $section_handle,
'search' => 'excerpt:'.$q
];
After some research I found out that when I use this as the 'criteria' it works:
$criteria = [
'section' => $section_handle,
'excerpt' => "*{$q}*"
];
And now I wonder how to proceed. How can I either get the first example to work to search in the excerpt field, or add the OR title clause to my latest example where I am able to search in the excerpt field...
I hope this makes sense and that someone can point me in the right direction!
Thanks very much,
Wouter