Project

General

Profile

Feature #38402 » any-searchable-text-should-perform-AND-search.patch

Go MAEDA, 2023-04-05 18:38

View differences:

app/models/issue_query.rb
end
fetcher = Redmine::Search::Fetcher.new(
question, User.current, ['issue'], projects, attachments: '0'
question, User.current, ['issue'], projects, all_words: (operator != '!~'), attachments: '0'
)
ids = fetcher.result_ids.map(&:last)
if ids.present?
test/unit/query_test.rb
assert_equal [1, 2, 3], result.map(&:id).sort
end
def test_filter_any_searchable_with_multiple_words
User.current = User.find(1)
query = IssueQuery.new(
:name => '_',
:filters => {
'any_searchable' => {
:operator => '~',
:values => ['recipe categories']
}
}
)
result = find_issues_with_query(query)
assert_equal [2], result.map(&:id)
end
def test_filter_any_searchable_with_multiple_words_negative
User.current = User.find(1)
query_result_ids = ->(op, value) do
query = IssueQuery.new(
:name => '_',
:filters => {'any_searchable' => {:operator => op, :values => [value]}}
)
find_issues_with_query(query).map(&:id).sort
end
ids_word1 = query_result_ids.call('~', 'recipe')
ids_word2 = query_result_ids.call('~', 'categories')
ids = query_result_ids.call('!~', 'recipe categories')
# Neither "recipe" nor "categories" are in the subject, description, notes, etc.
assert ids, Issue.ids.sort - ids_word1 - ids_word2
end
def test_filter_any_searchable_no_matches
User.current = User.find(1)
query = IssueQuery.new(
(5-5/8)