2016-06-07 40 views
1

使用维基百科的API的搜索功能:维基百科的API全文检索:只返回精确匹配

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

我想只接收其完全字符串匹配的结果,但是,这不是什么正在退回。

如何在API中引发此行为?

+0

使用引号:HTTPS:/ /en.wikipedia.org/w/api.php?action=query&list=search&srsearch=%22This%20Is%20An%20Example%22&srwhat=text (请参阅官方文档:https://www.mediawiki.org/wiki/说明:CirrusSearch#Prefer_phrase_matches) – leo

回答

1

没有太多添加到说什么狮子座:维基百科现在使用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" 
      } 
     ] 
    } 
}