2016-03-22 10 views
1

Ich verwende 'chewy' Edelstein für elasticsearch in meiner ROR-Anwendung. Aber ich habe keine Dokumentation für elasticsearch scroll api gefunden. Ich bekomme einen Fehler, wenn ich zur letzten Seite der Datensätze blicke.Wie benutze elasticsearch scroll api mit einem zähen Edelstein?

[500] {"error":{"root_cause":[{"type":"query_phase_execution_exception","reason":"Result window is too 
large, from + size must be less than or equal to: [10000] but was [19450]. See the scroll api for a more 
efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] 
index level parameter."}],"type":"search_phase_execution_exception","reason":"all shards failed", 
"phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"recordings","node":"tgLqH_wwRUG6NmY0PCB0nA", 
"reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must 
be less than or equal to: [10000] but was [19450]. See the scroll api for a more efficient way to request 
large data sets. This limit can be set by changing the [index.max_result_window] index level 
parameter."}}]},"status":500} 

Gibt es eine Möglichkeit, elasticsearch scroll api in chewy Juwel zu implementieren oder ist ihre andere Option?

+0

mit Es ist wie jetzt, wie der aussieht, 17. August 2016, Chewy hat ein offener Fehler für die Verwendung von Chewy mit der Scroll-API: https://github.com/toptal/chewy/issues/327 –

Antwort

0

So stellen Sie die Abfrage Größe kleiner und Sie können blättern in Chargen verwenden:

# @example Call the `scroll` API until all the documents are returned 
    # 
    #  # Index 1,000 documents 
    #  client.indices.delete index: 'test' 
    #  1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i}"} end 
    #  client.indices.refresh index: 'test' 
    # 
    #  # Open the "view" of the index by passing the `scroll` parameter 
    #  # Sorting by `_doc` makes the operations faster 
    #  r = client.search index: 'test', scroll: '1m', 
       body: {size: 100, sort: ['_doc']} 
    # 
    #  # Display the initial results 
    #  puts "--- BATCH 0 -------------------------------------------------" 
    #  puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect 
    # 
    #  # Call the `scroll` API until empty results are returned 
    #  while r = client.scroll(scroll_id: r['_scroll_id'], scroll: '5m') and not r['hits']['hits'].empty? do 
    #  puts "--- BATCH #{defined?($i) ? $i += 1 : $i = 1} -------------------------------------------------" 
    #  puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect 
    #  puts 
    #  end 

genommen Beispiel aus here die Elasticsearch DSL Gem

Verwandte Themen