简体   繁体   English

按与PHP的相关性排序结果

[英]Sort results by relevance with PHP

I have a search engine that, depending on what the users inputs, displays elements in an array in order of viewCount, uploadDate, and rating, but relevance is kicking my butt; 我有一个搜索引擎,根据用户的输入,按照viewCount,uploadDate和rating的顺序显示数组中的元素,但相关性正在踢我的屁股; I have no clue where to start. 我不知道从哪里开始。

First, data is retrieved from multiple xml/json feeds. 首先,从多个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);

Second, all the data is stored in an array. 其次,所有数据都存储在一个数组中。

Finally, the elements in the array are displayed for the user and sorted by either view count, upload date, or rating. 最后,为用户显示数组中的元素,并按视图计数,上载日期或评级进行排序。

Can someone point me in the right direction? 有人能指出我正确的方向吗? I am trying to learn how to calculate relevance. 我正在努力学习如何计算相关性。

Your problem is not related to a specific programming language, but more precisely of the algorithm used. 您的问题与特定的编程语言无关,但更准确地说与所使用的算法无关。 First, try to determine a good algorithm to express relevance as a number. 首先,尝试确定一个好的算法来表示作为数字的相关性。 For example, you can try to start from ranking or relevancy . 例如,您可以尝试从排名相关性开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM