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.

Parameters

NameTypeDescription
argsarrayThe 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.
provider_idstringThe engine that runs the query, wp_core, elasticpress or relevanssi.

Returns

array: The WP_Query arguments.

Example

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;
  }
);
  • kimaai_kb_search_meta_filter: narrows the vector search.
  • kimaai_keyword_search_providers: the engines the keyword search can use.

What are your feelings