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.

Define timeout for a "count"

See original GitHub issue

It seems like it is possible to pass a timeout argument to a search:

 es.search(
    index=my_index,
    doc_type='actions',
    timeout = '900',
    body=
    {
        "size": 0,
        "query": {
            "constant_score": {
                "filter": {
                    "terms": {
                        "ID":  IDs
                    }
                },
                "boost": 1.2
            }
        }
    })

It is then possible to count the number of documents by looking at the ['hits']['total']. A more direct approach would be to use the Elasticsearch.count. However, when doing so it is not possible to pass a timeout argument. A workaround is to use a search with the search_type set to count.

Doesn’t it make sense to have also for the count the possibility to set a timeout?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
honzakralcommented, Sep 9, 2014

global parameter timeout sets the timeout on the socket, per-request parameter request_timeout does the same. The reason it’s named differently is because in some cases the APIs already have a parameter named timeout that does something else (internal timeout within elasticsearch).

I tried to document this in the docs: http://elasticsearch-py.readthedocs.org/en/master/api.html#timeout

please let me know if that’s confusing or what could be clearer there, thanks!

1reaction
honzakralcommented, Sep 9, 2014

The default is 10 seconds for the global timeout (mentioned in [0]) and if request_timeout is not specified the global timeout will be used.

Yes, the search API is an example of an API that allows for the timeout parameter that will just be passed to elasticsearch.

0 - http://elasticsearch-py.readthedocs.org/en/master/connection.html#connection

Read more comments on GitHub >

github_iconTop Results From Across the Web

Counter in set Timeout nested in set interval is summed ...
My intent is to have the counter updated once every time the set timeout function is called. But it seems that the callback...
Read more >
Count() method giving error Timeout expired - MSDN
Count() method giving error Timeout expired - The timeout period elapsed prior to completion of the operation or the server is not responding....
Read more >
Time-out (sport) - Wikipedia
In sports, a time-out or timeout is a halt in the play. This allows the coaches of either team to communicate with the...
Read more >
setTimeout() - Web APIs - MDN Web Docs
The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
Read more >
Setting Timeout and Retry Count correctly for HTTP import ...
When calling a service with a HTTP import binding, how do I set timeout and retry values according to my needs ?
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