Git Product home page Git Product logo

Comments (4)

generall avatar generall commented on May 27, 2024

Hi @fadi212! Can you please elaborate on the issue? Are there any errors in client/service logs?

from qdrant-client.

sainivedh19pt avatar sainivedh19pt commented on May 27, 2024

@fadi212 Hi, In the Qdrant_Client class theres a upsert method to add new points. Maybe you could give it a try

Thanks

from qdrant-client.

imneonizer avatar imneonizer commented on May 27, 2024

I am trying to achieve the same, here is a quick reproducible code

# create random data
np.random.seed(0)
embeddings = np.array([np.random.rand(64) for i in range(100)])
labels = [{"label": str(i)} for i in range(100)]
  • This works
client.upload_collection(
    collection_name="test",
    vectors=embeddings,
    payload=labels,
    parallel=2
)

# uploading all the embeddings at once
res = client.search(
        collection_name="test",
        query_vector=embeddings[0],
        query_filter=None,
        append_payload=True,
        limit=1
    )

print(res[0].payload["label"])

# output is 0, since labels are basically index of each embedding
  • This doesn't works
# upload first 50 items
client.upload_collection(
    collection_name="test",
    vectors=embeddings[:50],
    payload=labels[:50],
    parallel=2
)

# upload remaining items
client.upload_collection(
    collection_name="test",
    vectors=embeddings[50:],
    payload=labels[50:],
    parallel=2
)

res = client.search(
        collection_name="test",
        query_vector=embeddings[0],
        query_filter=None,
        append_payload=True,
        limit=1
    )

print(res[0].payload["label"])

# output is 94, which is incorrect

I read about upsert method but I am not able to update the collections as per the requirement I have shown in the above example. It will be very helpful If someone can share snippets to update the collection.


Update: A work around to update/add records

from qdrant_client.http.models import PointStruct
points = [PointStruct(id=i, payload=labels[i], vector=embeddings[i].tolist()) for i in range(50, 100)]

client.upsert(
    collection_name="test",
    points=points,
    wait=True
)

from qdrant-client.

generall avatar generall commented on May 27, 2024
client.upload_collection(
    collection_name="test",
    vectors=embeddings[50:],
    payload=labels[50:],
    parallel=2
)

This doesn't work because ids are not specified. upload_collection can auto-generate Ids, but it starts with 0.

from qdrant-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.