Semantic-Org/Semantic-UI · error
Cannot search. No source used, and Semantic API module was n
Error message
Cannot search. No source used, and Semantic API module was not included
What it means
Search has two ways to get data: a local source (settings.source as object/array) or a remote call through the Semantic UI api module ($.fn.api). In query() (search.js:528-538) it picks local only when source is a plain object/array, otherwise falls to module.search.remote only if $.fn.api exists; if neither holds it logs error.source. It is also logged in search.object() (search.js:619-621) when the source argument is undefined/false.
Source
Thrown at src/definitions/modules/search.js:1299
onSearchQuery : function(query){},
onResults : function(response){},
onResultsOpen : function(){},
onResultsClose : function(){},
className: {
animating : 'animating',
active : 'active',
empty : 'empty',
focus : 'focus',
hidden : 'hidden',
loading : 'loading',
results : 'results',
pressed : 'down'
},
error : {
source : 'Cannot search. No source used, and Semantic API module was not included',
noResults : 'Your search returned no results',
logging : 'Error in debug logging, exiting.',
noEndpoint : 'No search endpoint was specified',
noTemplate : 'A valid template name was not specified.',
oldSearchSyntax : 'searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.',
serverError : 'There was an issue querying the server.',
maxResults : 'Results must be an array to use maxResults setting',
method : 'The method you called is not defined.'
},
metadata: {
cache : 'cache',
results : 'results',
result : 'result'
},
regExp: {
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,View on GitHub (pinned to 597843ab84)
Solutions
- Provide a local dataset: settings.source = [{ title: '...' }, ...] so search uses the local path.
- Include the api module before search: load semantic-ui-api.js (or the api sub-module) and set apiSettings.url so remote search is available.
- Confirm $.fn.api is defined at runtime (typeof $.fn.api !== 'undefined') before relying on remote search.
Example fix
// before
$('.ui.search').search(); // no source, no api module -> [81]
// after (local)
$('.ui.search').search({ source: [{title:'A'}, {title:'B'}] });
// after (remote, requires semantic-ui-api)
$('.ui.search').search({ type: 'category', apiSettings: { url: '/api/search?q={query}' } }); Defensive patterns
Strategy: validation
Validate before calling
// Ensure at least one data path is available
var hasLocal = $.isPlainObject(cfg.source) || $.isArray(cfg.source);
var hasApi = typeof $.fn.api !== 'undefined';
if (!hasLocal && !hasApi) {
throw new Error('Search needs a local source or the semantic-ui-api module loaded.');
}
$('.ui.search').search(cfg); Type guard
function isLocalSource(s){ return $.isPlainObject(s) || $.isArray(s); } Prevention
- Always provide settings.source for local search.
- Confirm $.fn.api is loaded before enabling remote search.
- Remember source must be an object/array, not a URL string, for the local path.
When it happens
Trigger: Initializing $('.ui.search').search() with no source setting while the api module (semantic-api) is not loaded; OR calling .search('search local', term) / object search with settings.source unset; OR settings.source is a string (e.g. a URL) instead of an object/array and $.fn.api is undefined.
Common situations: Forgetting to include semantic-ui-api.js after semantic-ui-search.js; expecting the api module to ship with search by default; setting source to a URL string thinking search will fetch it directly (search.js only treats plain objects/arrays as local data); tree-shaking/bundling that drops the api module.
Related errors
- No search endpoint was specified
- A valid template name was not specified.
- searchFullText setting has been renamed fullTextSearch for c
- There was an issue querying the server.
- Results must be an array to use maxResults setting
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/16aed1c6c0a95e04.
Report an issue: GitHub.