【问题标题】:Wikipedia API full text search: only return exact matchesWikipedia API 全文搜索:仅返回完全匹配
【发布时间】:2016-06-07 04:26:45
【问题描述】:

使用 Wikipedia API 的搜索功能:

https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=This%20Is%20An%20Example&srwhat=text

我只想接收与字符串完全匹配的结果,但是,这不是返回的结果。

如何在 API 中引发这种行为?

【问题讨论】:

标签: php wikipedia-api


【解决方案1】:

leo 说的没什么可补充的:维基百科现在使用 CirrusSearch 扩展,所以在使用 search API 时,您必须参考 https://mediawiki.org/wiki/Help:CirrusSearch#Prefer_phrase_matches,它告诉您 use quotation marks

{
    "batchcomplete": "",
    "continue": {
        "sroffset": 1,
        "continue": "-||"
    },
    "query": {
        "searchinfo": {
            "totalhits": 1100
        },
        "search": [
            {
                "ns": 0,
                "title": "Woman in a Purple Coat",
                "snippet": "costume, surrounded by a complex of abstract design and exotic color. <span class=\"searchmatch\">This</span> <span class=\"searchmatch\">is</span> <span class=\"searchmatch\">an</span> <span class=\"searchmatch\">example</span> of one of the final groups of oil paintings in Matisse's career, in",
                "size": 1347,
                "wordcount": 96,
                "timestamp": "2016-10-20T16:52:48Z"
            }
        ]
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    • 2022-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多