Module: Caoutsearch::Search::PointInTime
- Included in:
- Base
- Defined in:
- lib/caoutsearch/search/point_in_time.rb
Instance Method Summary collapse
- #close_point_in_time(pit_id) ⇒ Object
- #open_point_in_time(index: index_name, keep_alive: "1m") ⇒ Object
- #opened_points_in_time ⇒ Object
Instance Method Details
#close_point_in_time(pit_id) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/caoutsearch/search/point_in_time.rb', line 11 def close_point_in_time(pit_id) results = client.close_point_in_time(body: {id: pit_id}) results.body rescue ::Elastic::Transport::Transport::Errors::NotFound # We dont care if the PIT ID is already expired end |
#open_point_in_time(index: index_name, keep_alive: "1m") ⇒ Object
6 7 8 9 |
# File 'lib/caoutsearch/search/point_in_time.rb', line 6 def open_point_in_time(index: index_name, keep_alive: "1m") results = client.open_point_in_time(index: index, keep_alive: keep_alive) results["id"] end |
#opened_points_in_time ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/caoutsearch/search/point_in_time.rb', line 18 def opened_points_in_time results = client.indices.stats(index: index_name, metric: "search,shard_stats") open_contexts = results.dig("_all", "total", "search", "open_contexts") number_of_shards = results.dig("_all", "primaries", "shard_stats", "total_count") open_contexts / number_of_shards end |