Skip to content

Add "add if not exists" functionality to pysolr #367

Description

@Fikavec

Pysolr add() function has a parameter "overwrite" with behavior:

  • if overwrite is "true" and document with unique id existing then Solr delete it and add to collection as new document. As a result, if after first document adds it has been updated, we lost thease changes.

  • if overwrite is "false", Solr just assume this document is unique and add to collection with same uniq id and other version field value. As a result we have many documents with same uniq id:
    <uniqueKey>id</uniqueKey>
    image

To solve this problem add to pysolr add/_update function boolean parameter createIfNotExists (or parameter to control _version_ ) as:
if createIfNotExists: query_vars.append("_version_=-1")

In documentation https://solr.apache.org/guide/6_6/updating-parts-of-documents.html#UpdatingPartsofDocuments-OptimisticConcurrency

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions