Silent error when re-adding a primary key during document addition #115
curquiza
started this conversation in
Feedback & Feature Proposal
Replies: 2 comments 1 reply
-
100% agreed. From my POV, MeiliSearch should raise an error when the user tries (voluntarily or not, knowingly or not) to change the primary key, because this is technically not possible. Other than that, sending the same primary key (as in the loop example) shouldn't raise any error or even warning. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@gmourier this one can interest you |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, we can add the primary key of an index when adding/updating documents.
The first time the script is run, the index will be created and the primary key will be set to
numero
.If I re-launch the script, the index is already created, and so is the primary key. But MeiliSearch does not throw any error despite a primary key is already present and the user might want to be informed about this.
This silent error might be problematic if the user tries to send a different primary key compared to the one that is stored in the index: he/she is clearly doing something that he/she should not do.
However, if the primary key that is sent is the same primary key that is already set up, I personally don't like with the fact of raising an error since it brings an unpleasant user experience when coding.
Indeed, users usually send documents by batch, so in a loop, like this:
Here it will not fail at the first call, but it will at the second one. So the users would need to create an index first with the primary key. This is not convenient: we might not want to make this kind of complexity back (create an index first) knowing that we succeeded to remove it with the implicit index creation handling.
Conclusion
The silent error is problematic: the users should know what they are doing if they are doing something wrong. However, if the primary key sent is the same as the one already stored, they are not in a dangerous situation when manipulation MeiliSearch.
A solution would be to raise an error only if the primary key sent is different from the primary key already set in the index.
Discussed with @MarinPostma about the problematic silent error.
Suggestion of improvement coming from @bidoubiwa and @eskombro.
Beta Was this translation helpful? Give feedback.
All reactions