Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `.
Expand Down
18 changes: 18 additions & 0 deletions spec/mongoid/timeout_option_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading