---
name: kimaai_keyword_search_query_args
type: filter
since: 1.5.4
tier: premium
feature: knowledge-base
area: embedding-search
summary: Changes the WP_Query arguments of the keyword search that hybrid search adds to the knowledge search.
parameters:
  - name: args
    type: array
    description: The WP_Query arguments, with s (the search query), post_type, post_status publish, posts_per_page, and lang and tax_query when the search is scoped.
  - name: provider_id
    type: string
    description: The engine that runs the query, wp_core, elasticpress or relevanssi.
returns:
  type: array
  description: The WP_Query arguments.
surfaces: [chatbot, search]
---

# kimaai_keyword_search_query_args

## When it fires

Each time the knowledge search runs with hybrid search on (Chatbot, Knowledge base, Hybrid search), before the keyword search is sent to its engine: WordPress's own search, ElasticPress (which then adds `ep_integrate`) or Relevanssi. SearchWP builds its own query and does not pass it. The keyword hits are merged with the vector hits by rank.

Whatever the query returns, KimaAI keeps only published posts without a password that the visitor may see and that are in the search's scope. The query asks for three times "Keyword results to fuse", at most 50, so that enough are left after that.

## Example

```php
add_filter(
  'kimaai_keyword_search_query_args',
  function (array $args): array {
    // The keyword search leaves out the dealer documents, as the knowledge search does.
    $args['tax_query'][] = [
      'taxonomy' => 'audience',
      'field' => 'slug',
      'terms' => ['dealers'],
      'operator' => 'NOT IN',
    ];

    return $args;
  }
);
```

## Related

- `kimaai_kb_search_meta_filter`: narrows the vector search.
- `kimaai_keyword_search_providers`: the engines the keyword search can use.
