Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Concerns about primary key behaviour #92

Closed
MarinPostma opened this issue Feb 19, 2021 · 3 comments
Closed

Concerns about primary key behaviour #92

MarinPostma opened this issue Feb 19, 2021 · 3 comments

Comments

@MarinPostma
Copy link
Contributor

While I was writing tests for transplant, I was testing the following:

  • create an index with primary key primary
  • add a document, and set primary key to primaru (testing that this is ignored):
{"primaru": 1, "text": "tata"}

I was expecting that there would be an error, since I have set the primary key to some value, and handed a document that doesn't contain this field. Yet this seems perfectly acceptable. Furthermore, when querying for the document back, I get:

[
  {
    "primaru": 1,
    "text": "tata"
  }
]

So there are no notion of the primary key. The document was given an id, but I have no way of knowing which. This is concerning, since as a user I specifically requested that a primary key is used, and yet, it is ignored.

Here is what I think should be the behaviour:

  • If the primary key is not set, and the engine can infer it, then it is set to the inferred value.
  • If it can't be infered, the engine creates a id field for each document, and uses it as a primary key. This fields should be added to all documents, and retrieved when doing a GET documents.
  • If the primary key is set, either manually or by any of the previous manners, then a document that lack this primary key causes the addition to fail with an error.
@MarinPostma
Copy link
Contributor Author

Furthermore, I realized that when performing an empty document addition, the primary_key is still inferred to be id, but an empty document addition, with no primary_key in the request, should be considered as a no-op.

@curquiza
Copy link
Member

Hello! Is this issue blocking to make transplant iso with MeilISearh? Should this be fixed?

@MarinPostma
Copy link
Contributor Author

closed by #180

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants