1

I need to index multiple documents in bulk with making them available to search as soon as possible. So, I want to use refresh in order to suffice this requirement.

I am currently using the code like this below. Taking example from official site

def gendata():
    mywords = ['foo', 'bar', 'baz']
    for word in mywords:
        yield {
            "_index": "mywords",
            "_type": "document",
            "doc": {"word": word},
        }

bulk(es, gendata())

I wish to attach a refresh=true to make it visible instantly.

Can you please help me know of this is possible with python bulk API?

Parth Pandya
  • 39
  • 1
  • 12

1 Answers1

3

You can use the refresh parameter:

bulk(es, gendata(), refresh="true")

The bulk function documentation does not mention this parameter, but it is described in the bulk method documentation.

Basically, the bulk method has a refresh parameter; available values are:

  • "true"
  • "wait_for"
  • "false" (the default).

For more details, have a look at this question.

natka_m
  • 1,297
  • 17
  • 22