Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multi indexing #85

Merged
merged 2 commits into from
Dec 7, 2021
Merged

Allow multi indexing #85

merged 2 commits into from
Dec 7, 2021

Conversation

mdubus
Copy link
Member

@mdubus mdubus commented Dec 7, 2021

Pull Request

What does this PR do?

Closes #15

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

What's inside this PR ?

  • Renaming of the field queries into indexes
  • The indexes field is now an array and allows us to provide multiple indexes and queries for indexation
  • Separation of the validatePluginOptions in 2 functions : validatePluginOptions for the global plugin options, and validateIndexOptions for the validation of each indexes options
  • Update of the playground plugin config to pass the indexes as an array
  • Update of each tests name for better understanding of what it should do
  • Update of the tests with the new naming (indexes) + addition of a new test testing the multi-indexation

How to test ?

  • yarn test
  • yarn playground:dev and update the playground/gatsby-config.js by adding a second index (see example below). By going to your MeiliSearch's mini-dashboard (http://127.0.0.1:7700/ for me), you should see that the 2 indexes were created. You can also edit the INDEX_NAME inside playground/src/pages/index.js and see the changes on http://localhost:9000/

Example of second index :

 {
            indexUid: 'index2',
            transformer: data => data.allMdx.edges.map(({ node }) => node),
            query: `
              query MyQuery {
                allMdx {
                  edges {
                    node {
                      id
                    }
                  }
                }
              }
            `,
          },

@mdubus mdubus requested a review from bidoubiwa December 7, 2021 10:10
src/validate.js Outdated Show resolved Hide resolved
tests/index-to-meilisearch.test.js Outdated Show resolved Hide resolved
@mdubus mdubus force-pushed the allow_multi_indexing branch from 96b0a1d to caf52c9 Compare December 7, 2021 13:33
@mdubus mdubus force-pushed the allow_multi_indexing branch from caf52c9 to e77a8a6 Compare December 7, 2021 13:34
@mdubus mdubus requested a review from bidoubiwa December 7, 2021 13:39
Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥 🔥 🔥

@mdubus
Copy link
Member Author

mdubus commented Dec 7, 2021

bors merge

bors bot added a commit that referenced this pull request Dec 7, 2021
85: Allow multi indexing r=mdubus a=mdubus

# Pull Request

## What does this PR do?
Closes #15

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

## What's inside this PR ? 
- Renaming of the field `queries` into `indexes`
- The `indexes` field is now an array and allows us to provide multiple indexes and queries for indexation
- Separation of the `validatePluginOptions` in 2 functions : `validatePluginOptions` for the global plugin options, and `validateIndexOptions` for the validation of each indexes options
- Update of the playground plugin config to pass the `indexes` as an array
- Update of each tests name for better understanding of what it should do
- Update of the tests with the new naming (`indexes`) + addition of a new test testing the multi-indexation

## How to test ? 
- `yarn test`
- `yarn playground:dev` and update the `playground/gatsby-config.js` by adding a second index (see example below). By going to your MeiliSearch's mini-dashboard (http://127.0.0.1:7700/ for me), you should see that the 2 indexes were created. You can also edit the `INDEX_NAME` inside `playground/src/pages/index.js` and see the changes on http://localhost:9000/

Example of second index : 
```js
 {
            indexUid: 'index2',
            transformer: data => data.allMdx.edges.map(({ node }) => node),
            query: `
              query MyQuery {
                allMdx {
                  edges {
                    node {
                      id
                    }
                  }
                }
              }
            `,
          },
```

Co-authored-by: Morgane Dubus <morgane.d@meilisearch.com>
@mdubus
Copy link
Member Author

mdubus commented Dec 7, 2021

bors merge

@bors
Copy link
Contributor

bors bot commented Dec 7, 2021

Build succeeded:

@bors bors bot merged commit 0795970 into main Dec 7, 2021
@bors bors bot deleted the allow_multi_indexing branch December 7, 2021 14:00
@bidoubiwa bidoubiwa added the enhancement New feature or request label Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow multi-indexing
2 participants