question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to use bulk save

See original GitHub issue

elasticsearch version 1.4.2 elasticsearch-dsl-py version 0.0.11

elasticsearch-dsl-py is to support bulk save? how can I use bulk save with elasticsearch-dsl-py

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
j2kuncommented, May 9, 2017

For example, if I were to make a base class that looks like this:

class DocumentBase(DocType):
    @classmethod
    def bulk_save(cls, dicts):
        objects = (cls.create(d).to_dict(include_meta=True) for d in dicts)
        client = connections.get_connection()
        return bulk(client, objects)

How would I change this to do a bulk update/delete, or do bulk get’s in general?

13reactions
luoxiaoheicommented, May 29, 2018

@j2kun update/delete can use _op_type, it’s like

from elasticsearch_dsl.connections import connection
from elasticsearch.helpers import bulk

bulk(connection.get_connection(), (dict(d.to_dict(True), **{'_op_type': 'update'}) for d in DOCUMENTS))

upsert is like this

from elasticsearch_dsl.connections import connection
from elasticsearch.helpers import bulk

def upsert(doc):
    d = doc.to_dict(True)
    d['_op_type'] = 'update'
    d['doc'] = d['_source']
    d['doc_as_upsert'] = True
    del d['_source']

    return d

bulk(connection.get_connection(), (upsert(d) for d in DOCUMENTS))
Read more comments on GitHub >

github_iconTop Results From Across the Web

BULK INSERT (Transact-SQL) - SQL Server - Microsoft Learn
Specifies that BULK INSERT performs the import operation using the specified data-file type value. DATAFILETYPE value, All data represented in: ...
Read more >
PowerApps Bulk Save to SharePoint List Demo - YouTube
In this step-by-step tutorial video, I walk through how to save data in bulk to SharePoint List using PowerApps Collection. You can use...
Read more >
Bulk SaveChanges in EF Extensions (EFE)
The BulkSaveChanges try to combine most commands in a single operation. Updating different columns from an action to another will require generating different ......
Read more >
How to do bulk (multi row) inserts with JpaRepository?
To get a bulk insert with Spring Boot and Spring Data JPA you ... Or override the save(List) and use the entity manager...
Read more >
bulkSave - Velo API Reference - Wix.com
Use the options parameter to run bulkSave() from backend code without checking for permissions or without its registered hooks. When saving items to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found