GuidePlugin LogoGuidePlugin Docs

guideplugin/index/facet/dataset

Adjust records stored in the index table

guideplugin/index/facet/dataset

Definition

With this filter you can adjust the record that is stored in the index table.

This filter allows you to modify the dataset before it gets indexed, giving you control over how facet data is stored and displayed.

Parameters

apply_filters('guideplugin/index/facet/dataset', $dataset);
ParameterTypeDescription
$datasetarrayArray of the record stored in the index table

Dataset Structure

// Example
$dataset = array(
    'post_id' => 123,
    'facet_slug' => 'slug',
    'facet_value' => 200,
    'facet_display_value' => '200cm'
);

Example

The example shows you how to customize the record:

<?php 
function my_guide_index_facet_dataset($dataset) { 

    if ($dataset['facet_slug'] == 'height') {
        $dataset['facet_value'] = 300; 
        $dataset['facet_display_value'] = '300cm';
    } 
    return $dataset; 
}
add_filter('guideplugin/index/facet/dataset', 'my_guide_index_facet_dataset', 10, 1);

Usage Scenarios

Data Transformation

Convert values before indexing (e.g., unit conversions)

Display Values

Customize how facet values appear to users

Data Validation

Ensure data integrity before storage