Skip to content

How can I limit results of vector search based on injected source #846

Answered by georgeh0
petrarca asked this question in Q&A
Discussion options

You must be logged in to vote

You can add a new field when you collect the rows to be exported, to identify the source, e.g.

doc_embeddings.collect(
    source_key="/your/source/path/or/anything",
    filename=doc["filename"],
    location=chunk["location"],
    text=chunk["text"],
    embedding=chunk["embedding"],
)

Here the source_key can be any value (e.g. strings, integers). It will become an additional field in your exported database. You give different values for data from your different source. Likely you need this to be a primary key part too:

code_embeddings.export(
   // how can I add here additional data
    "my_table_name",
    cocoindex.targets.Postgres(),
    primary_key_fields=["source_key", "filename", "…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@petrarca
Comment options

@georgeh0
Comment options

@petrarca
Comment options

Answer selected by petrarca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants