Search in Bubble uses the Do a Search For operator with text constraints like 'contains' to match user input against database fields. This tutorial covers building a search bar with instant results, searching across multiple Data Types, displaying results in a unified list, optimizing search performance for large datasets, and adding search suggestions based on popular queries.
Overview: Search Functionality in Bubble
This tutorial teaches you how to implement search in your Bubble app. You will create a search input, connect it to database queries, display results dynamically, and handle edge cases like empty searches and large datasets.
Prerequisites
- A Bubble app with Data Types containing searchable records
- Basic understanding of Do a Search For and Repeating Groups
- Familiarity with the Design and Workflow tabs
- At least 10-20 records in your database for testing
Step-by-step guide
Add a search input and results area
Add a search input and results area
In the Design tab, add an Input element at the top of your page and set its placeholder to 'Search...'. Below it, add a Repeating Group that will display search results. Set the Repeating Group's type to the Data Type you want to search. Set the data source to Do a Search for [Type] with a constraint: the searchable field 'contains' the Input's value. Enable 'Ignore empty constraints' on the search so all records show when the input is empty. The results will update in real-time as the user types.
Expected result: Typing in the search input filters the Repeating Group to show matching records instantly.
Search across multiple fields
Search across multiple fields
To search across multiple fields simultaneously, you need to create a combined search approach. One method is to add a 'search_key' text field to your Data Type that concatenates the searchable fields (name, description, category). Update this field via a backend workflow whenever the record is created or modified. Then search against this single field. Alternatively, use the :merged with operator to combine multiple searches: Do a Search for Products (name contains input) :merged with Do a Search for Products (description contains input). The merged approach is simpler but less performant.
Pro tip: The search_key approach is faster because it runs one query instead of multiple. Update it with a database trigger that fires whenever the record changes.
Expected result: Search results include matches from any searchable field, not just one.
Display results with context
Display results with context
Inside each Repeating Group cell, display the record's primary fields: title, a short description snippet, and the category or type. Add an icon or image if available. To indicate why a result matched, use conditional formatting: if the name contains the search term, bold the name. If the description matched, show a snippet of the description with the matching text. Add a 'No results found' message using a Text element with a conditional: visible when the Repeating Group's list of items is empty and the search input is not empty.
Expected result: Search results show relevant record information with clear presentation and a no-results message when appropriate.
Optimize search for large datasets
Optimize search for large datasets
Bubble's text search constraints only index the first 256 characters of a text field. For large datasets, avoid using :filtered after a search — always use constraints directly. Paginate results to 10-20 items. If you need full-text search across thousands of records, consider using an external search service like Algolia or Typesense via the API Connector, which provides much faster search with fuzzy matching and typo tolerance. For simpler optimization, add a debounce by not triggering the search until the user pauses typing for 300ms using a custom state and scheduled custom event.
Expected result: Search performs efficiently even with large datasets through proper constraints and pagination.
Add search suggestions and recent searches
Add search suggestions and recent searches
Create a 'SearchQuery' Data Type with fields: query (text), user (User), count (number), and timestamp (date). When a user performs a search and selects a result, save or increment the SearchQuery record. Display popular searches as suggestions below the input when it is focused but empty: Do a Search for SearchQuery sorted by count descending, limited to 5. Also show the current user's recent searches: Do a Search for SearchQuery where user = Current User sorted by timestamp descending, limited to 5.
Expected result: Users see popular and recent search suggestions when they click on the search input.
Complete working example
1SEARCH FUNCTIONALITY SUMMARY2=====================================34BASIC SEARCH:5 Input: Search bar with placeholder6 RG data source: Do a Search for [Type]7 Constraint: field contains Input's value8 Enable: Ignore empty constraints9 Results update as user types1011MULTI-FIELD SEARCH:12 Option A: search_key field13 Concatenate: name + description + category14 Update via database trigger15 Search: search_key contains Input's value16 Option B: Merged searches17 Search 1: name contains input18 :merged with19 Search 2: description contains input2021RESULTS DISPLAY:22 Cell: title (bold if matched), description,23 category, image24 No results: Text visible when RG empty25 and input is not empty2627OPTIMIZATION:28 Use constraints, not :filtered29 Text indexing: first 256 characters only30 Paginate to 10-20 results31 Debounce: 300ms delay before searching32 External: Algolia/Typesense for 10K+ records3334SEARCH SUGGESTIONS:35 SearchQuery Data Type:36 query, user, count, timestamp37 Popular: Sort by count desc, limit 538 Recent: Filter by Current User, limit 539 Save query on result selectionCommon mistakes when implementing Search Functionality in Bubble
Why it's a problem: Using :filtered instead of search constraints for text matching
How to avoid: Use 'contains' as a search constraint directly in Do a Search For
Why it's a problem: Searching text fields longer than 256 characters
How to avoid: Create a separate search_key field limited to 256 characters with the most important searchable text
Why it's a problem: Not handling the empty search state
How to avoid: Add a condition to hide the results Repeating Group when the search input is empty, or show a different default view
Best practices
- Use search constraints instead of :filtered for all text matching
- Create a search_key field for searching across multiple fields efficiently
- Paginate search results to 10-20 items
- Show a clear no-results message when the search finds nothing
- Add debounce to avoid searching on every keystroke
- Save popular queries for search suggestions
- Test search with various input lengths and special characters
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to build a search feature in my Bubble.io app that searches products by name, description, and category. How do I set up the search to be fast and search across all three fields?
Help me build a search bar that searches my Products database by name and description, shows results as the user types, and displays 'No results found' when nothing matches.
Frequently asked questions
Does Bubble support full-text search?
Bubble supports basic text matching with 'contains' constraints. For advanced full-text search with fuzzy matching and relevance ranking, integrate an external service like Algolia via the API Connector.
How fast is search in Bubble?
With proper constraints and indexing, Bubble search returns results in 100-500ms for datasets under 10,000 records. Larger datasets may need external search services.
Can I search across multiple Data Types?
Yes. Run separate searches for each Data Type and display results in separate Repeating Groups, or use a unified search_key approach with a common searchable field.
Does search work with non-English text?
Yes. Bubble's contains constraint works with any Unicode text including accented characters, CJK characters, and special symbols.
How do I add search to my mobile layout?
Use the same search logic but place the input at the top of the page with the results below. On mobile, consider a full-screen search overlay that appears when the search icon is tapped.
Can RapidDev help build advanced search for my Bubble app?
Yes. RapidDev can implement advanced search features including multi-field search, external search service integration, and AI-powered search for your Bubble application.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation