Closed curquiza closed 3 years ago
Hey, It's me again, can I take this issue? @curquiza
Hello again! 😄 Of course you can! I assign you!
Also, can you add the same to updateDocuments
? So sorry for this addition.
I've updated the issue description and title.
Ok, no problem. Can you explain to me more about how to pass that param or how to overwrite the primaryKey? And if you do not mind giving a query example
This is useful to pass the primary key as a query parameter the first time you add or update documents if the primary key has not been inferred or set before.
If you want to pass the primary key, just pass it as a query parameter:
$ curl
-X POST 'http://localhost:7700/indexes/movies/documents?primaryKey=id
--data '[{
"id": 287947,
"title": "Shazam",
"poster": "https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg",
"overview": "A boy is given the ability to become an adult superhero in times of need with a single magic word.",
"release_date": "2019-03-23"
}]'
If the primary-key has been already set/inferred, you can still pass it as a query parameter but the parameter will be just ignored. It's maybe not the perfect way to handle it, but MeiliSearch does not handle warnings for the moment. So you don't need to check a primary key exists: just pass it to the MeiliSearch server, it will handle it.
Got it. But, I just testing and every time I made your example, it needs to match the query parameter
with the id name
something like your example, but if I do this:
$ curl
-X POST 'http://localhost:7700/indexes/movies/documents?primaryKey=id
--data '[{
"movie_id": 287947,
"title": "Shazam",
}]'
Notice that the query parameter is different from the data. The document won't be created. So, if you have an idea of how to start this issue, let me know.
In your example, because the primary key is id
, the document is not created because MeiliSearch does not find any id
field in the document. For MeiliSearch, there is no primary key and it cannot add a document without it.
So you don't have to care about this when doing this issue (add a parameter to both methods). This is how MeiliSearch works, not the Java client.
With your example, when getting the update status with this method, can you confirm the error you can see? More about the document addition response -> https://docs.meilisearch.com/faq/#i-did-a-call-to-an-api-route-and-i-only-got-an-updateid-as-a-response-what-does-it-mean
@curquiza Hello can I work on this issue? I'm investigating how these methods work.
Hello @OmarMorales71! Thanks for your involvement! @JohanDelValleV seemed to want to do this issue: https://github.com/meilisearch/meilisearch-java/issues/78#issuecomment-742761443 . Maybe should we wait for a little and ask him before starting it?
However, if you want to do an issue, I've just opened this one #93 which is really important and useful for this repo 😄
Since this issue was inactive for more than 10 months, I took the liberty to send a PR for this, hope it's okay. @curquiza
The
addDocument
andupdateDocuments
methods do not take any primary key as parameter, but they should. Related docs:⚠️ The primary key parameter should be optional!