discourse/spec/support/ts_vector_matcher.rb
Sam 651476e89e
FIX: domain searches not working properly for URLs (#20136)
If a post contains domain with a word that stems to a non prefix single
words will not match it.

For example: in happy.com, `happy` stems to `happi`. Thus searches for happy
will not find URLs with it included.

This bloats the index a tiny bit, but impact is limited.

Will require a full reindex of search to take effect. 

When we are done refining search we can consider a full version bump.
2023-02-03 09:55:28 +11:00

22 lines
640 B
Ruby

# frozen_string_literal: true
RSpec::Matchers.define :eq_ts_vector do |expected_vector|
match do |actual_vector|
actual = actual_vector.split(" ").sort
expected = expected_vector.split(" ").sort
(expected - actual == []) && (actual - expected == [])
end
failure_message do |actual_vector|
actual = actual_vector.split(" ").sort
expected = expected_vector.split(" ").sort
message = +"ts_vector does not match!\n\n"
message << "Additional elements:\n"
message << (expected - actual).join("\n")
message << "\nMissing elements:\n"
message << (actual - expected).join("\n")
message
end
end