-
Notifications
You must be signed in to change notification settings - Fork 43
feat(environment): Added functionality to perist entries from different instance. #116
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,9 @@ module.exports = { | |||||||
| matchFields: ['slug', 'modified'], // Array<String> default: ['modified'] | ||||||||
| concurrentQueries: false, // default: true | ||||||||
| skipIndexing: true, // default: false, useful for e.g. preview deploys or local development | ||||||||
| continueOnFailure: false // default: false, don't fail the build if algolia indexing fails | ||||||||
| continueOnFailure: false, // default: false, don't fail the build if algolia indexing fails | ||||||||
| useEnvironment: 'blog', // default: false, used in conjunction with enablePartialUpdates let you persist entries from different environment | ||||||||
| environmentKey: 'product', // default: 'environment', key used when useEnvironment is set. | ||||||||
|
Comment on lines
+86
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| }, | ||||||||
| }, | ||||||||
| ], | ||||||||
|
|
@@ -128,6 +130,9 @@ If you pass `replicaUpdateMode: 'replace'` in the index settings, you can choose | |||||||
|
|
||||||||
| If you pass `replicaUpdateMode: 'merge'` in the index settings, the replica settings will combine the replicas set on your dashboard with the additional ones you set via index settings here. | ||||||||
|
|
||||||||
| ### Persisting entries | ||||||||
| If you want to persist entries that are added to the index (for example added by the different gatsby instance if your index is combining several websites) you can set `useEnvironment` to unique string that represents given instance. All entries with different `environment` value will be ignored. You can change the key accordingly using `environmentKey`. | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also needs updating based on that |
||||||||
|
|
||||||||
| ## Concurrent Queries | ||||||||
|
|
||||||||
| Sometimes, on limited platforms like Netlify, concurrent queries to the same index can lead to unexpected results or hanging builds. Setting `concurrentQueries` to `false` makes it such that queries are run sequentially rather than concurrently, which may solve some concurrent access issues. Be aware that this option may make indexing take longer than it would otherwise. | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -115,6 +115,8 @@ | |||||||
| chunkSize = 1000, | ||||||||
| enablePartialUpdates = false, | ||||||||
| matchFields: mainMatchFields = ['modified'], | ||||||||
| useEnvironment = false, | ||||||||
| environmentKey = 'environment' | ||||||||
|
Comment on lines
+118
to
+119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } = config; | ||||||||
|
|
||||||||
| activity.setStatus( | ||||||||
|
|
@@ -173,6 +175,9 @@ | |||||||
|
|
||||||||
| // iterate over existing objects and compare to fresh data | ||||||||
| for (const [id, existingObj] of Object.entries(indexedObjects)) { | ||||||||
| if (useEnvironment && existingObj[environmentKey] !== useEnvironment) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also need to check that similar to matchFields, it's present on all new objects |
||||||||
| continue; | ||||||||
| } | ||||||||
| if (queryResultsMap.hasOwnProperty(id)) { | ||||||||
| // key matches fresh objects, so compare match fields | ||||||||
| const newObj = queryResultsMap[id]; | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems confusing, what if we have only the option
environmentKey, and use it whenever it's set. I think also the option on line 86 possibly has the wrong example value? (is it a boolean or a string?)