Skip to content

feat: add deleteBy, batched auto-save, source roundtrip#1

Merged
ilvalerione merged 6 commits into
neuron-core:mainfrom
danielebarbaro:feat/delete-by
Jun 4, 2026
Merged

feat: add deleteBy, batched auto-save, source roundtrip#1
ilvalerione merged 6 commits into
neuron-core:mainfrom
danielebarbaro:feat/delete-by

Conversation

@danielebarbaro
Copy link
Copy Markdown
Contributor

@danielebarbaro danielebarbaro commented May 28, 2026

Summary

Implements deleteBy(sourceType, ?sourceName) and a few supporting changes, as discussed on ezimuel/PHPVector#7.

PHPVector exposes the primitives (metadataSearch() from #4, deleteDocument() from #3), so this PR composes them.
No neuron-core/neuron-ai dependency is added to PHPVector.

Changes

  • sourceType / sourceName round-trip: folded into PHPVector metadata as reserved keys on write; restored and stripped from metadata on read in similaritySearch. Enables deleteBy to filter on them.
  • deleteBy(sourceType, ?sourceName): builds an ANDed MetadataFilter list, runs metadataSearch, deletes each match via deleteDocument, then persist().
  • deleteBySource(...) (deprecated by the interface) becomes a one-line delegate.
  • Configurable batched auto-save: new bool \$autoSave = true constructor flag; persist() calls save() once per public mutation, gated by \$autoSave && \$database->isPersistent() so in-memory databases are skipped. The pre-existing manual-save path is kept on a single test.
  • README: usage, persistence semantics (answering the load/save question from #7), autoSave, deletion.

Dependency

Requires ezimuel/phpvector ^0.3.0 (now stable on Packagist).

@danielebarbaro danielebarbaro changed the title WIP - TBD deleteBy via metadata filtering feat: add deleteBy, batched auto-save, source roundtrip May 28, 2026
@danielebarbaro danielebarbaro marked this pull request as ready for review May 28, 2026 14:48
@ilvalerione ilvalerione merged commit c3c67eb into neuron-core:main Jun 4, 2026
1 of 10 checks passed
@ilvalerione
Copy link
Copy Markdown
Contributor

Thank you Daniele for the contribution.

I thought to simplify the usage of this component managing the creation of a new database or loading an exsting one automatically inside the PHPVector class.

So now the adapter just get the path of the directory to store database information instead of forcing developers to implement the check logic:

class MyRAG extends RAG
{
    ...

    protected function vectorStore(): VectorStoreInterface
    {
        return new PHPVector(
            path: '/var/data/mydb',
            topK: 5,
        );
    }
}

Here is the code: https://github.com/neuron-core/php-vector/blob/main/src/PHPVector.php#L33-L41

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants