Experimental plugin for AI-driven search by Crocoblock. This plugin is literally AI search for your website. Allows parse you website content by Open AI and than search over parsed content also using Open AI possibilities. Returns a lot more better results than default WordPress search. One more advantage over deafult search - spelling insensetivity.
Step 1
Install and activate plugin (as usual WP plugin)
Step 2
Go to Settings/AI Search
Set up your Open AI API key and adjust other settings like you need (but better t test other settings later, when you set up all data)
Step 3
Fetch some starting content, because plugin will work only with own fetched fragments, not content directly.
Step 4
Enable required post types for auto-fetch. Auto fetch is required to plugin automatically update fragmnets when you create/update/delete posts of selected post type.
Next code snippet allow you to add value from meta field to parsed content fragments. Using this you can run AI search by selected custom field values, not only posts content/excerpt.
add_filter( 'jet-ai-search/post-fragments', function( $fragments, $post, $parser ) {
// Optional part - making sure we work with posts of need type
if ( 'product' !== $post->post_type ) {
return $fragments;
}
// Getting field value
$field_name = 'description-for-the-search';
$custom_description = get_post_meta( $post->ID, $field_name, true );
// If value is empty - nothing to do here
if ( ! $custom_description ) {
return $fragments;
}
// Reset previously parsed stack and store new fragment
$parser->reset_results();
$parser->set_stack_defaults( [
'post_id' => $post->ID,
'post_url' => $post->guid,
'post_title' => $post->post_title,
'source' => $post->post_type,
] );
// Optional - store post title with field value for better context
$title = $parser->prepare_heading( $post->post_title );
$fragment = $parser->prepare_fragment( $custom_description );
$parser->stack_result( [
'fragment' => $title . $fragment
], true );
// Merge stored fragment with all previous fragmnets
$fragments = array_merge( $fragments, $parser->get_result() );
return $fragments;
}, 10, 3 );
After adding this code, you need to re-fetch content of required post type to make sure new fragments stored in DB.