{"record":{"id":"c4af0dbcc5a05022","repo":"jackwener/OpenCLI","slug":"wikidata-search-no-wikidata-items-matched-quer","errorCode":null,"errorMessage":"wikidata search: No Wikidata items matched \"${query}\" in language \"${language}\".","messagePattern":"wikidata search: No Wikidata items matched \"(.+?)\" in language \"(.+?)\"\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/wikidata/search.js","lineNumber":35,"sourceCode":"    args: [\n        { name: 'query', positional: true, required: true, help: 'Search keyword (label / alias)' },\n        { name: 'language', default: 'en', help: 'Search & display language (ISO 639, e.g. en, fr, zh)' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max items (1-50)' },\n    ],\n    columns: ['rank', 'qid', 'label', 'description', 'matchType', 'matchText', 'url'],\n    func: async (args) => {\n        const query = requireString(args.query, 'query');\n        const language = requireLanguage(args.language);\n        const limit = requireBoundedInt(args.limit, 20, 50);\n        const url = `${WIKIDATA_BASE}/w/api.php?action=wbsearchentities`\n            + `&search=${encodeURIComponent(query)}`\n            + `&language=${encodeURIComponent(language)}`\n            + `&uselang=${encodeURIComponent(language)}`\n            + `&type=item&format=json&limit=${limit}&origin=*`;\n        const body = await wikidataFetch(url, 'wikidata search');\n        const list = Array.isArray(body?.search) ? body.search : [];\n        if (!list.length) {\n            throw new EmptyResultError('wikidata search', `No Wikidata items matched \"${query}\" in language \"${language}\".`);\n        }\n        return list.slice(0, limit).map((item, i) => {\n            const qid = String(item?.id ?? '').trim();\n            return {\n                rank: i + 1,\n                qid,\n                label: typeof item?.label === 'string' ? item.label : null,\n                description: typeof item?.description === 'string' ? item.description : null,\n                matchType: typeof item?.match?.type === 'string' ? item.match.type : null,\n                matchText: typeof item?.match?.text === 'string' ? item.match.text : null,\n                url: qid ? `${WIKIDATA_BASE}/wiki/${qid}` : '',\n            };\n        });\n    },\n});\n","sourceCodeStart":17,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikidata/search.js#L17-L51","documentation":"The wikidata search command calls wbsearchentities and requires a non-empty body.search array. When Wikidata returns zero matches for the query in the requested language, an EmptyResultError is thrown with this message. This is a 'no results' condition, not a failure of the request itself.","triggerScenarios":"Calling `wikidata search <query> --language <lang>` where the wbsearchentities response's search array is empty — misspelled terms, very obscure subjects, or terms with no labels in the requested language.","commonSituations":"Searching in a language where the concept has no Wikidata label (e.g. a rare term in 'zh-hans'); misspelling the search term; searching for a property/lexeme concept that search (item-only by default) cannot find.","solutions":["Retry with a broader or corrected query string","Search with --language en, which has the broadest label coverage, then inspect labels in other languages","Check the term exists at wikidata.org via the web search UI","If looking for properties or lexemes, note the adapter's search returns Q-ID items by default"],"exampleFix":"// before\nawait runCli(['wikidata', 'search', 'Duglas Adams', '--language', 'fr']);\n// after\nawait runCli(['wikidata', 'search', 'Douglas Adams', '--language', 'en']);","handlingStrategy":"fallback","validationCode":"if (!query || !query.trim()) throw new Error('search query must be non-empty');\nif (language && !/^[a-z]{2,3}(-[a-z]{2,8})?$/.test(language)) throw new Error('bad language code');","typeGuard":null,"tryCatchPattern":"try {\n    const results = await runCli(['wikidata', 'search', query, '--language', lang]);\n} catch (e) {\n    if (/No Wikidata items matched/.test(e.message)) {\n        // fall back to English or a broader query\n        results = await runCli(['wikidata', 'search', query, '--language', 'en']);\n    } else throw e;\n}","preventionTips":["Default to English when the target language may lack labels","Normalize/broaden queries before searching","Treat empty results as data, not failures, in pipelines","Confirm the term exists via the Wikidata web UI when debugging"],"tags":["empty-result","search","wikidata"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}