ElementAPI : Excluding terms from search criteria I am trying to exclude terms in my search when using the element api. I have successfully managed to include terms and search them by fields in my entries. I would now like to be able to exclude different terms in those fields. 

In this case 'recipeIngredients' is a matrix field. 

Here is my criteria search so far : 

//Get search query text
$searchQuery = Craft::$app-&gt;request-&gt;getQueryParam('searchQuery');
//Search in either title or ingredients
if ($searchQuery) $criteria['search'] = "title:'".$searchQuery."' OR recipeIngredients:'".$searchQuery."'";

//Get excluded ingredients query
$excludedQuery = Craft::$app-&gt;request-&gt;getQueryParam('xq');
if ($excludedQuery) {
    if (!isset($criteria['search'])) {
        $criteria['search'] = '';
    } else {
        $criteria['search'] = $criteria['search'].' AND ';
    }
    $criteria['search'] = $criteria['search']."recipeIngredients: not '".$excludedQuery."'";
}

//Get result count
$count = Craft::$app-&gt;request-&gt;getQueryParam( 'count' );
$count = $count ? $count : 10;//Default to ten if no parameter

return [
    'elementType'     =&gt; Entry::class,
    'criteria'        =&gt; $criteria,
    'elementsPerPage' =&gt; $count,
    'transformer'     =&gt; function ( Entry $entry ) {
        return [
            'name'      =&gt; $entry-&gt;title,
            'url'        =&gt; $entry-&gt;url,
            //'json_url'    =&gt; UrlHelper::url( "recipe/{$entry-&gt;id}.json" ),
            'picture_url' =&gt; $entry-&gt;recipeImage-&gt;one()-&gt;getUrl(),
            'portions'   =&gt; (float)$entry-&gt;recipePortions,
            'time'       =&gt; [
                'total' =&gt; (float)$entry-&gt;recipeTotalTime
            ]
        ];
    },
];


I can't figure out if I should be trying to append the excluded terms to the search query, and my syntax is wrong, or if there is another criteria property available to exclude results. 

Also, the ElementQuery page mentionned in the docs no longer exists. I assume, it's this page, but I'm not certain.
Here is what I ended up changing my code to exclude search items. 

//Get excluded ingredients query
$excludedQuery = Craft::$app-&gt;request-&gt;getQueryParam('xq');
if ($excludedQuery) {
    if (!isset($criteria['search'])) {
        $criteria['search'] = '';
    } else {
        $criteria['search'] = $criteria['search'].' ';
    }
    $criteria['search'] = $criteria['search']."-title:'".$excludedQuery ."' -recipeIngredients:'".$excludedQuery ."' ";
}