[英]Sort results by relevance with PHP
我有一個搜索引擎,根據用戶的輸入,按照viewCount,uploadDate和rating的順序顯示數組中的元素,但相關性正在踢我的屁股; 我不知道從哪里開始。
首先,從多個xml / json提要中檢索數據。
$url1 = "http://api.site1.com/?q=$userinput";
$url2 = "http://api.site2.com/?q=$userinput";
$url3 = "http://api.site3.com/?q=$userinput";
//get_and_decode is a function that gets and decodes data from the xml/json feed
get_and_decode($url1);
get_and_decode($url2);
get_and_decode($url3);
其次,所有數據都存儲在一個數組中。
最后,為用戶顯示數組中的元素,並按視圖計數,上載日期或評級進行排序。
有人能指出我正確的方向嗎? 我正在努力學習如何計算相關性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.