Skip to content

Conversation

@MattieBelt
Copy link

@MattieBelt MattieBelt commented Jul 13, 2021

This draft PR is a way to discuss/review the changes and choices I made in the forked package @mattiebelt/strapi-plugin-meilisearch

Use case

An user has multiple Strapi collection types in his portfolio, he has Projects, Blogs and Tools. He want to create one search bar that can search multiple indexes. As of now, this isn't available with Meilisearch.

Solution

Use one index for multiple collection types, so have a combined index (e.g. portfolio)

Problem

Currently you can only enable or disable the indexing of objects per collection type with strapi-plugin-meilisearch.
You are not able to specify an custom index in which the objects should be created.

Changes I made

  • Only allow configuration by file (disabled UI), so this applies for:
    • Credentials
    • Collection types
  • Configure an index for an collection type (e.g. { name: 'project', index: 'portfolio' })
  • In the overview:
    • Separate the num. of objects in the index and the rows in the collection
    • Show the name of the index

Why choose for file config only.

After first trying to make an index editable through the Admin panel, I ran into problems. The getCollections method does return based on `strapi.contentTypes, which make it not possible to save any options per collection type. So the way the collection types are handled must first be changed to allow an index to be configured through the Admin panel. Because this meant there needed to be made to much changes, I choose for file configurations with some hot glue, to just make it work. 😉

My goal was only to make this possible for the use case from above and I also knew the code wasn't ready to be merged into this repo, that's why I choose to publish an scoped package.

Example

module.exports = () => ({
    meilisearch: {
      apiKey: "masterKey",
      host: "http://localhost:7700",
      collections: [
          { name: 'project', index: 'global' },
          { name: 'category' },
          { name: 'restaurant', index: 'global' }
        ]
    }
  })

image

Related Issues

@curquiza
Copy link
Member

curquiza commented Aug 2, 2021

Hello @MattieBelt! Thanks for this PR. Once you finished the PR, please make it "Ready for review", don't let it as a draft. Then ping @bidoubiwa, she will review your PR! (at the moment she's on vacation)
Thanks again for this contribution 🙂

@MattieBelt
Copy link
Author

Hey @curquiza,

This PR was intentionally created as a draft, because it more so a way to discuss the idea of configurable indexes with you guys.
I talked with @bidoubiwa about it and she asked me to create this draft PR 😉

Hey Mattie thanks so much for the effort you put into this. Could you make a PR just to be able to see the diffs and the choices you applied? You can open it in draft so that there is no confusion. We will be able to bullet point what is inside your fork and determine what is good to keep and what needs further discussion.

She said she would later look into this PR, after the v0.21 release.

But no rush on it, it can wait.

@tvvignesh
Copy link

@MattieBelt Thanks a lot for this 🙏🏼 Will wait for the release. We use strapi and we have done everything in the website except for search. I will be the first user when we have this merged 🙂

@bidoubiwa
Copy link
Contributor

Hey @MattieBelt I will be working on this review and on the repo in itself the following weeks :) Sorry for the delay

@bidoubiwa
Copy link
Contributor

Closed in favor of #288

@bidoubiwa bidoubiwa closed this Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants