Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

ActiveModel::RangeError (35693 is out of range for ActiveModel::Type::Integer with limit 2 bytes) #66

Open
Tectract opened this issue Nov 29, 2021 · 1 comment

Comments

@Tectract
Copy link

I have a really long article with a "body" field that is fuzzily searchable. At some point it starts taking a long time for fuzzily to re-index / update the search trigrams for the article when I click "update" on my web form and it does the article.save! in my rails application.

Eventually it crashes with this error!

Trigram Exists (0.7ms)  SELECT  1 AS one FROM "trigrams" WHERE "trigrams"."trigram" = $1 AND "trigrams"."owner_type" = $2 AND "trigrams"."owner_id" = $3 AND "trigrams"."fuzzy_field" = $4 LIMIT $5  [["trigram", "**<"], ["owner_type", "Article"], ["owner_id", 1094], ["fuzzy_field", "body"], ["LIMIT", 1]]
App 11471 output:    (0.5ms)  ROLLBACK
App 11471 output: Completed 500 Internal Server Error in 517ms (ActiveRecord: 84.7ms)
App 11471 output:   
App 11471 output: ActiveModel::RangeError (35693 is out of range for ActiveModel::Type::Integer with limit 2 bytes):

This is bad. I believe it's because the trigram "score" is really high and because of this line:

t.integer "score", limit: 2

Specifically I think it's because it's an article with a lot of html symbols and it seems to be searching for a trigram on "**<" which is a little odd, but ok.

In the trigrams migration. I need this limit to be higher I guess. removing the 2-byte limit with a migration, date_update_trigrams_score.rb ...

class UpdateTrigramsScore < ActiveRecord::Migration[5.2]
  # allow higher fuzzily scores for long searchable article bodies...
  def change
    change_column :trigrams, :score, :integer
  end
end 

and my problem is resolved. So, maybe 2 bytes is a little too low for normal usage on the trigrams score?

@Tectract
Copy link
Author

I think I will just have to disable trigram search on the body field of my articles, as it indexes way too many items, takes too long, when the articles are more than a page or two long. I want to be able to put whole novels into my article bodies, so maybe trigram search just isn't the right tool for searching the bodies of the articles, or really long texts in general...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant