Skip to content

Feature: Add "Match contains" dropdown option for substring search#11

Merged
anthony-tom1 merged 3 commits intomainfrom
search-contains-option
Feb 8, 2026
Merged

Feature: Add "Match contains" dropdown option for substring search#11
anthony-tom1 merged 3 commits intomainfrom
search-contains-option

Conversation

@anthony-tom1
Copy link

@anthony-tom1 anthony-tom1 commented Feb 8, 2026

Files Changed

Theme:
vendor/nodebb-theme-harmony-main/templates/search.tpl
vendor/nodebb-theme-harmony-2.1.35/templates/search.tpl

Language:
public/language/en-US/search.json - en-US language
public/language/en-GB/search.json - en-GB language

Core:
src/search.js

Plugin (node_modules):
node_modules/nodebb-plugin-dbsearch/lib/mongo.js
node_modules/nodebb-plugin-dbsearch/lib/postgres.js
node_modules/nodebb-plugin-dbsearch/lib/redis.js

Description

  • Adds a third case-insensitive search mode, "Match contains", to the advanced search dropdown so users can search by substring (e.g. “lo wo” matches “Hello World!”).
  • Previously only “Match all words” and “Match any word” dropdown options were available.
  • Redis search is word-based and does not support substring search. For the new “Match contains” mode, the plugin gets candidate IDs from the index (using only category and user filters when present, otherwise from the full index set). It loads post and topic content via NodeBB’s posts and topics modules, filters by case-insensitive substring in application code, applies filters and result limit, and returns the result list.
  • In public/language/en-US/search.json and public/language/en-GB/search.json the key match-contains was added with the value "Match contains". The advanced search template uses [[search:match-contains]], so the dropdown label is taken from these files.

Feature Demo
Screenshots showing "Match contains" search in local NodeBB server.
Screenshot 2026-02-08 at 5 09 55 PM
Screenshot 2026-02-08 at 5 10 16 PM

- Adds a new “Contains” option to the search match dropdown (theme + i18n)
- Preserves existing “match all” and “match any” word-based behavior
- Implements case-insensitive substring matching for bookmarks and dbsearch backends
- MongoDB uses regex-based matching; Postgres uses ILIKE
- Redis backend behavior remains unchanged
- Renames the label for the match-contains option in en-US search.json
- Adds match-contains field with value "Match contains" in en-GB search.json
@coveralls
Copy link

Pull Request Test Coverage Report for Build 21806329526

Details

  • 0 of 5 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 78.828%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/search.js 0 5 0.0%
Totals Coverage Status
Change from base Build 21804929697: -0.01%
Covered Lines: 25357
Relevant Lines: 30331

💛 - Coveralls

@anthony-tom1 anthony-tom1 merged commit 86878cb into main Feb 8, 2026
1 check passed
@marcuscmu marcuscmu linked an issue Feb 11, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: create search bar

2 participants

Comments