• Resolved tommy94

    (@tommy94)


    I am looking to use the Typesense plugin to pull two custom post types merge them and then index them to Typesense into a single index.

    I am unsure how to go about this, currently the plugin pulls each custom post type and indexes them separately. Is there a built in solution already or a way to solve this problem?

    If it is not currently possible, is it possible to add this as a feature?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Sachyya

    (@sachyya-sachet)

    Hello @tommy94

    To index two custom post types into one single index, you have to follow these steps below:
    1. Create a new schema that matches both post types using cm_typesense_schema hook
    2. Then format the data as per the schema using cm_typesense_data_before_entry

    Here’s a sample gist for that: https://gist.github.com/sachyya/3be2d1e970684749a482320f6868fe89

    Hope this helps!!!

    Regards

    Thread Starter tommy94

    (@tommy94)

    Hi @sachyya-sachet

    Thanks for the response, I have added your solution in but I do no have cpts-data as a selection to index in the typesense plugin drop down.

    I have tried to hook in “cm_typesense_available_index_types” to add my index but as it’s not a post type it won’t display, do you have a solution to this?

    Kind regards,
    Tommy

    Plugin Contributor digamberpradhan

    (@digamberpradhan)

    Hi @tommy94,

    Please review the following documentation on how to add custom post types to be available in the dropdown here :
    https://docs.wptypesense.com/advanced-custom-post-types/
    Additionally please not you will have to delete and re-index the posts once (and only once) before your schema changes can take effect.

    Hi! I also need to do the same thing ??

    I need to render several Collections ( seperate post types ) as 1, whithout switcher by CollectionMenu.

    As I understand I need to create another Collection with all post types togeter. I managed to do that. But faced with the issue that Post on update is not pushed its changes to Typesense. So I would have to manually Delete and Index all posts after a single change on any post.

    Can you please give me a hint how to push single Post changes in update?

    Plugin Contributor digamberpradhan

    (@digamberpradhan)

    @sbdev1stepan

    Hi – this won’t be a feature in the main plugin for now.
    And at the moment we are building an addon that will make this possible https://github.com/codemanas/omni-search/.

    The provided addon will work but you must be mindful of the schema for the post types.

    Got it! Thank you for the answer!

    Do you have a timeframe for the development of this addon?

    Plugin Contributor digamberpradhan

    (@digamberpradhan)

    @sbdev1stepan currently we don’t have a fixed timeframe on this – as this isn’t considered part of the core feature set and we’re looking at this more as R&D – meaning the feature set has not been locked right now.

    Dom

    (@jgmdom)

    Hi @sachyya-sachet

    I have followed the gist above to  index two custom post types into one single index. However, I am also having the same issues as @tommy94 in that it doesn’t appear in the index selection.

    I can see digamberpradhan added a link to adding a custom post type, however this is not a custom post type it’s just a schema so how can I add and index this?

    Regards
    Dom

    Dom

    (@jgmdom)

    Just to add to this, I’ve attempted to add using the link above and was able to get ‘cpts-data’ to show in the selection using this code:

    function cm_typesense_add_available_post_types( $available_post_types ) {
        $available_post_types['cpts-data'] = [ 'label' => 'CPT Data', 'value' => 'CPT Data' ];
        return $available_post_types;
    }
    add_filter( 'cm_typesense_available_index_types',  'cm_typesense_add_available_post_types');

    However, if I refresh the page it disappears and if I try to Delete and Re-Index I get error “Not Found : No collection with name cpts-data found.”

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Merge custom post types into a single index’ is closed to new replies.