Daman Stancill
10/09/2024, 2:26 PMsweet & sour meatballs
vs. sweet & sour meatb alls
These two queries return very different results – the second one doesn’t really return any results from the first one.
Right now space is a token separator in the schema. We’ve tried using the split_join_tokens
search parameter, but we cannot get
Schema
add_filter('typesense_schema', function ($collectionName) {
return [
'name' => $collectionName,
'fields' => [
[
'name' => '.*',
'type' => 'auto',
],
[
'name' => 'post_title',
'type' => 'string',
'sort' => true,
'infix' => true,
],
// ... other fields
// sorting fields
[
'name' => 'post_type_weight',
'type' => 'int32',
],
],
'default_sorting_field' => 'post_type_weight',
'token_separators' => [" ", "-", "_", ".", "'", "\""],
'symbols_to_index' => ["&"],
];
});
Search params
$search_params = [
'q' => !empty($params['search']) ? $params['search'] : '*',
'query_by' => 'post_title,primary_parent_category,post_excerpt,post_content_sanitized,search_meta,taxonomy_post_tag',
'query_by_weights' => '127,68,1,1,1,1',
'page' => $page,
'per_page' => $per_page,
'sort_by' => $sort_by,
'filter_by' => $filter_by,
];
We’ve tried all sorts of combinations of these additional search parameters:
'split_join_tokens' => 'always', // Treat space as typo
'typo_tokens_threshold' => 3,
'num_typos' => 4,
Any suggestions on how to handle this would be greatly appreciated!