weaviate-python-client icon indicating copy to clipboard operation
weaviate-python-client copied to clipboard

Add create_or_replace like method

Open FlorisHoogenboom opened this issue 3 years ago • 4 comments

For many use cases I find myself wanting to have a sort of create or replace kind of method when writing records to Weaviate. I don't know if it is an explicit design choice to not include this in the API, but if you would be open to it I would be happy to contribute it.

FlorisHoogenboom avatar Dec 28 '22 21:12 FlorisHoogenboom

Hi @FlorisHoogenboom,

The current create already works as an add_or_replace. Weaviate automatically updates entries that already exist and there is nothing to do from the client side.

dirkkul avatar Jan 02 '23 16:01 dirkkul

Hi @dirkkul, I'm experiencing different behaviour though. Also judging from this section it seems that the current create does not function as an add or replace?

https://github.com/semi-technologies/weaviate-python-client/blob/572a9d401eda68bc17a9f6e876f996ac6d1a9213/weaviate/data/crud_data.py#L139

Am I missing a sort of global configuration option?

FlorisHoogenboom avatar Jan 05 '23 14:01 FlorisHoogenboom

Hi @FlorisHoogenboom ,

ahh you're right. I was thinking about batches. There, existing objects are replaced. (If you add a lot of objects I'd recommend using batches instead of adding single objects)

Then I don't see any reason against having a create_or_replace function, @StefanBogdan are you ok with that?

dirkkul avatar Jan 05 '23 19:01 dirkkul

I am for it, but I think it should be on the Server side not on the client side. As a temporary solution we could implement such a method.

StefanBogdan avatar Jan 06 '23 14:01 StefanBogdan