Support updating the primary key of an index to nil #682
macraig
started this conversation in
Feedback & Feature Proposal
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Moved from meilisearch/meilisearch-go#449 by https://github.com/Mandrenkov
Description
To my best knowledge, it is not currently possible to update the primary key of an index to
nil
. Sure, you can create an index with anil
primary key, but if you change the primary key to some string, there is no way to update it back tonil
.Basic example
Ideally, it would be possible to write either
or
to update the primary key of
index
tonil
.Other
I'm no expert in Go or Meilisearch, but it looks like this might be the case because
is not annotated with
omitempty
as inand thus the server always receives
""
instead ofnull
.For some context, I'm looking into developing a Terraform provider for Meilisearch in order to manage Meilisearch indices using configuration files (as opposed to manual API calls or scripts). For example, I can configure a Meilisearch index using code which looks like this:
To do so, I'm using the Meilisearch Go library to perform CRUD operations on Meilisearch indices. For example, if I define a Meilisearch index using
I can create the index using
CreateIndex(&IndexConfig{Uid: "foo"})
and the primary key is set tonull
as expected. If I then decide to set another primary key as inI can simply call
UpdateIndex("bar")
and the primary key is set tobar
. So far, so good! But now, if I change my mind and decide I'm not sure what the primary key should be and go back tothere is no way, using the Meilisearch Go library, to set the primary key back to
null
!Well, the issue is that there is no way to update the primary key to
null
. If I try to use something likethe primary key is set to
""
(instead ofnull
). Of course, trying to calldirectly results in a type error as
string
values cannot benil
.I don't have any documents in the index. My use case is configuring the index before uploading documents to it.
Perhaps it would help if I phrased this issue another way. Suppose that you have an index, with UID
foo
, with a primary key set tobar
. After looking into the requirements some more, you realize you can't predict the primary key ahead of time and would like Meilisearch to guess it. Unfortunately, there is no way you can update the primary key to benil
now and so your only course of action is to delete indexfoo
and then recreate it with anull
primary key!Beta Was this translation helpful? Give feedback.
All reactions