Git Product home page Git Product logo

cm-typesense-docs's People

Contributors

bidhip avatar digamber89 avatar dipin-bajra avatar sachyya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cm-typesense-docs's Issues

Best result on search is not bringing it's group (post type) to top of result

Currently when I do an exact match search, the post is found but it is contained inside its custom post type grouping, and that grouping does not change rank order. That post type is last in the "Post Types to Enable" list. Don't we think that the matching priority should be taken into account before the order of the Posts Types to Enable grouping?

Adding ACF Flexible Content Layout fields to schema

Hello,

The bulk of the content on the site I'm working on is in ACF Flexible Content Layout fields on Posts and Pages.

I'm assuming I would have to add the schema for these fields for them to be indexed in search. I have roughly 20 layouts, each with its own subfields. What is the best way to include all of these fields in the schema?

Additionally, what are the options for type in this fields array:

'fields' => [
    [ 'name' => 'post_content', 'type' => 'string' ],
    [ 'name' => 'post_title', 'type' => 'string' ],
    [ 'name' => 'post_type', 'type' => 'string' ],
    [ 'name' => 'post_author', 'type' => 'string' ],
    [ 'name' => 'comment_count', 'type' => 'int64' ],
    [ 'name' => 'is_sticky', 'type' => 'int32' ],
    [ 'name' => 'post_excerpt', 'type' => 'string' ],
    [ 'name' => 'post_date', 'type' => 'string' ],
    [ 'name' => 'post_id', 'type' => 'string' ],
    [ 'name' => 'post_modified', 'type' => 'string' ],
    [ 'name' => 'id', 'type' => 'string' ],
    [ 'name' => 'permalink', 'type' => 'string' ],
    [ 'name' => 'post_thumbnail', 'type' => 'string' ],
    [ 'name' => 'genre', 'type' => 'string[]', 'facet' => true ]
],
// ...

Thanks!

JavaScript hooks

Are there any events triggered in JavaScript that I can hook into? I have two things I'd like to achieve

  1. analytics integration - everytime a user searches for a term, or clicks on a link I'd like to send some data to our GA property
  2. alternate trigger for launching the Instant Search box. Currently I'm using the 'Replace WordPress Search' option but ideally i'd like to just have a search icon that i can click on to launch the Instant Search box.

rangeSlider - how to customize the displayed value ?

Hello,
I'm not sure if I set up this correctly but I would like to have a facet that allows to search within the posts by publication date
So here under is what I did (I just kept one other facet as example (lcr_post_theme which is a custom taxonomy). It works, my lcr_post_theme facet and the slider, but the displayed value of the rangeSlider are unix timestamp, how can display maybe only the year, ofrbetter, the full date in a format like this: 2024-08-26
Here is the code, the settings and visual result...
Any help welcome !

add_filter('cm_typesense_schema', function ($schema, $name) {
           if ($name == 'post') {
               $schema['fields'][] = ['name' => 'lcr_post_theme', 'type' => 'string[]', 'optional' => true, 'facet' => true];
               // add a date range filter
               $schema['fields'][] = ['name' => 'publication_date', 'type' => 'int64', 'optional' => true, 'facet' => true];
           }

           return $schema;
       }, 10, 2);

       add_filter('cm_typesense_data_before_entry', function ($formatted_data, $raw_data, $object_id, $schema_name) {
           if ($schema_name == 'post') {
               // theme
               $lcr_post_theme = [];
               $terms = get_the_terms($object_id, 'lcr_post_theme');
               if ($terms) {
                   foreach ($terms as $term) {
                       $lcr_post_theme[] = $term->name;
                   }
               }

               // date should be an int64
               $formatted_data['publication_date'] = strtotime(get_the_date('Y-m-d', $object_id));
               // $formatted_data['publication_date'] = get_the_date('Y-m-d', $object_id); // -> this creates an error while indexing
           }

           return $formatted_data;
       }, 10, 4);

       /** Add the genre option to available index list **/

       add_filter('cm_typesense_available_index_types', function ($available_post_types) {
           $available_post_types['lcr_post_theme'] = ['label' => 'Thèmes', 'value' => 'lcr_post_theme', 'type' => 'taxonomy'];
           // not sure if this needed
           $available_post_types['publication_date'] = ['label' => 'Date de publication', 'value' => 'publication_date', 'type' => 'date'];

           return $available_post_types;
       });

       add_filter('cm_typesense_enabled_taxonomy_for_post_type', function ($taxonomies) {
           $taxonomies[] = 'lcr_post_theme';
           // not sure if this is needed as well
           $taxonomies[] = 'publication_date';

           return $taxonomies;
       });

       add_filter('cm_typesense_filter_type', function ($filterType, $filterName) {
           if ($filterName == 'publication_date') {
               $filterType = 'rangeSlider';
           }

           return $filterType;
       }, 10, 2);



       // add_filter('cm_typesense_search_facet_settings', function ($facet_settings, $facet) {
       //     if ($facet == 'publication_date') {
       // I guess it is here that I may customize somethin gbut how ??

       //     }

       //     return $facet_settings;
       // }, 10, 2);

Capture 2024-08-26 à 11 24 32
Capture 2024-08-26 à 11 27 20

Hierarchal Menu Implementation for Categories

Feature request : Allow use of Hierarchal menu for Instant Search :
https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/

The pros :
Allows user to show category - sub category filter system that would be useful for customers to get data.

The cons:
WordPress by default does not distinguish category levels. What does this mean ?
WordPress records Parent for a category but - it does not by default save which level a category is.

So for example a category - sub category system like Clothing > Men > T-shirts
Here, Clothing is level 1 - Men is level 2 - T shirts is level 3.
However the Categories are not stored in WordPress with these levels associated with them.
So when a post is indexed - these calculations need to be made , so we would have to get the highest parent of the category tree
For 3 or less levels this should be fine - BUT - for larger nesting of categories - this would be quite resource intensive.

A possible solution for now is to allow users to implement this system but with the warning of the associated risk.

I am of the opinion that since this could potentially crash / consume large resources in some use cases - it would not be a good idea to provide this as a configurable option on the product for now - rather we should provide code samples that allow this to be implemented.

Autocomplete Highlighting

Autocomplete does not currently have search results highlighting.
This is currently not available on Autocomplete
Whereas Algolia Autocomplete currently has support for this Algolia Autocomplete

Algoia autocomplete has default support for querying - we would need to adapt this for typesense. Maybe a feature to turn on or off highlighting for shortcode.

No custom post types appearing in Instant Search

Not sure if I've misconfigured something, but I've added a few additional post types - Podcasts, Videos. When I replace the WordPress search with Autocomplete, I can see that they are included in the search results, but when I replace the WordPress search with Instant Search, it only searches Posts.

How to use customized Typesense collection

The search bar from my WordPress page should present the results based on the website content and an external documentation page. I have tried to combine all Typesense collections. However, I don't know how I can replace the collections used by the plugin:

image

Is it possible to use customizable collections with the Search with Typesense plugin?

Search term highlighting + combining collections.

Hello,

  1. Search Term Highlighting: I was able to get search results using the plugin to index Posts and Pages and then using the JavaScript client to query via the API for my headless site. Yet, the returned results do not have the search term highlighted or surrounded by <mark></mark> tags. According to the API docs, this should be on by default. Is there a way to get highlighting working when coming from WordPress? In the Typesense admin, when performing a search the term is highlighted there as seen here:

CleanShot 2024-07-10 at 20 35 39@2x

Alternatively, there is also the JSON format as shown here:

CleanShot 2024-07-10 at 20 37 49@2x

CleanShot 2024-07-10 at 20 36 37@2x

Is there a way to get that JSON returned from search instead of the normal document? With that I could display the highlighted snippet instead of an excerpt. I guess that is more a Typesense API question but I have not found a way to do it.

  1. Combining collections. In the Typesense docs, they recommend combining collections into one e.g. posts | pages and then querying against that to provide a global search. How would I go about doing that with the plugin? Is there a function to combine the different indices?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.