2016-06-07 66 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" 
      } 
     ] 
    } 
}