From c0058593fe6ef2783587ee70dcfb17d138ef58f4 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Fri, 16 Oct 2026 23:00:56 -0400 Subject: [PATCH] Document and cover class-level indexing timeout options Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 1 + README.md | 2 ++ spec/mongoid/timeout_option_spec.rb | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 spec/mongoid/timeout_option_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b817f7..0c74c5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.8.3 (Next) +* [#59](https://github.com/mongoid/mongoid_fulltext/pull/59): Document and cover class-level indexing timeout options - [@dblock](https://github.com/dblock). * [#51](https://github.com/mongoid/mongoid_fulltext/pull/51): Modernize CI through Ruby 4.0, Mongoid 9, and MongoDB 8 with real coverage, RuboCop 1.92, and fork-safe Danger workflows - [@dblock](https://github.com/dblock). * [#45](https://github.com/mongoid/mongoid_fulltext/pull/45): Allow for class level ngram updates to not timeout - [@roykolak](https://github.com/roykolak). * Your contribution here. diff --git a/README.md b/README.md index c52d0d9..1efbe1f 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,8 @@ had never been defined - you see both models that both pass and fail the filter Indexing Options ---------------- +`Artwork.update_ngram_index(timeout: false)` rebuilds the index for all records without a cursor timeout; the `timeout` option belongs to the class method, not the per-document `artwork.update_ngram_index` method. + Additional indexing/query options can be used as parameters to `fulltext_search_in`. * `alphabet`: letters to index, default is `abcdefghijklmnopqrstuvwxyz0123456789 `. diff --git a/spec/mongoid/timeout_option_spec.rb b/spec/mongoid/timeout_option_spec.rb new file mode 100644 index 0000000..d9b32a0 --- /dev/null +++ b/spec/mongoid/timeout_option_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'Class-level indexing timeout options' do + it 'rebuilds all records with cursor timeouts disabled' do + first = DelayedArtwork.create!(title: 'Flowers 1') + second = DelayedArtwork.create!(title: 'Flowers 2') + expect(DelayedArtwork.fulltext_search('flower')).to eq([]) + DelayedArtwork.update_ngram_index(timeout: false) + expect(DelayedArtwork.fulltext_search('flower')).to match_array([first, second]) + end + + it 'applies the no_timeout option to the class criteria' do + items = DelayedArtwork.all + expect(DelayedArtwork).to receive(:all).and_return(items) + expect(items).to receive(:no_timeout).and_call_original + DelayedArtwork.update_ngram_index(timeout: false) + end +end