mattermost/mattermost

[Bug]: OR search in Recent Mentions causes false positives

Open

#33,806 opened on Aug 28, 2025

View on GitHub
 (0 comments) (0 reactions) (1 assignee)TypeScript (32,880 stars) (7,823 forks)batch import
Help Wanted

Description

Before you file a bug report

Mattermost Server Version

10.9.0

Operating System

macOS 15.5

Steps to reproduce

  • This issue occurs when performing OR searches with multiple usernames.
  • Searches with a single username work fine.
  • There may be an issue with the search query parsing.
  • Affected features: Recent Mentions, general search functionality.

Expected behavior

  • Cause of the issue: The is_or_search parameter was not set correctly in the performSearch() function.
  • Affected file: webapp/channels/src/actions/views/rhs.ts
  • Fix: Set is_or_search to false to change to an AND search.

Observed behavior

OR searches are not handled correctly, and search results differ from what is expected or the search fails.

Log Output

NA

Additional Information

Test Conditions:

  • Login user: user-testlogin01
  • Test posts: (all 7posts)
    • @user-testlogin01 hi
    • @user-testlogin01 is_or_search false
    • hi all users
    • user-456
    • user
    • user-123
    • @user-12321eb958 hi

Test Results:

1. is_or_search: true (Current behavior)
curl -X POST http://localhost:8065/api/v4/posts/search \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"terms":"@user-testlogin01","is_or_search":true}'

Result: 7 posts (all) returned

  • ✗ All posts containing "user" were matched
  • ✗ Unintended partial matches included
  • ✗ Mentions to other users also included
2. is_or_search: false (Proposed fix)
curl -X POST http://localhost:8065/api/v4/posts/search \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"terms":"@user-testlogin01","is_or_search":false}'

Result: Only 2 posts returned

  • ✓ Only exact mentions to @user-testlogin01
  • ✓ No unintended partial matches
  • ✓ Clean, relevant results

Conclusion:

  • Problem identified: is_or_search: true causes false positives with partial matches
  • Solution: Use is_or_search: false for Recent Mentions to ensure only exact mention matches are returned
  • Impact: Eliminates false positives and improves search accuracy

Contributor guide