Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/03/2009, 08:48
josemadridista
 
Fecha de Ingreso: febrero-2007
Mensajes: 70
Antigüedad: 17 años, 2 meses
Puntos: 1
Buscador php,2 resultados (a lo google)

Hola tengo el siguiente desafio con php y mysql. He realizado un buscador pero si por ejemplo busco "foros del web" me salen las 10,000 paginas indexadas ordenadas segun importancia por enlaces. Lo que quiero hacer es que si busco "foros del web" tan solo me devuelva los primeros resultados por cada url. (Como google)
aqui parte de la orden mysql
Código PHP:
$query "select hostname,page,`title`,match(`text`,`title`,`anchor_text`,`hostname`,`page`) against(\"".owssize($my_search)."\") + match(`title`) against(\"".owssize($my_search)."\") as relevancy,match(`text`,`title`,`anchor_text`,`hostname`,`page`) against(\"".owssize($my_search)."\" in boolean mode) as wrdcount,id,rank, LEFT(`text`, 400),level from pages where match(`text`,`title`,`anchor_text`,`hostname`,`page`) against(\"".owssize($my_search)."\" in boolean mode) >=".(int)abs($minword)." order by wrdcount DESC,relevancy DESC,rank DESC limit "
He estado buscando en otras aplicacion para intentar adaptarlo pero estoy bastante perdido lo mas parecido que he encontrado que realice esto es el siguiente codigo pero no se como usarlo

Código PHP:
if ($merge_site_results == && $domain_qry == "") {
            while (list(
$key$value) = each($result_array_full)) {
                if (!isset(
$domains_to_show[$domains[$key]])) {
                    
$result_array_temp[$key] = $value;
                    
$domains_to_show[$domains[$key]] = 1;
                } else if (
$domains_to_show[$domains[$key]] ==  1) {
                    
$domains_to_show[$domains[$key]] = Array ($key => $value);
                }
            }
        } else {
            
$result_array_temp $result_array_full;
        }
    
        
        while (list(
$key$value) = each ($result_array_temp)) {
            
$result_array[$key] = $value;
            if (isset (
$domains_to_show[$domains[$key]]) && $domains_to_show[$domains[$key]] != 1) {
                list (
$k$v) = each($domains_to_show[$domains[$key]]);
                
$result_array[$k] = $v;
            }
        }

        
$results count($result_array);

        
$keys array_keys($result_array);
        
$maxweight $result_array[$keys[0]];


        for (
$i = ($start -1)*$per_page$i <min($results, ($start -1)*$per_page $per_page) ; $i++) {
            
$in[] = $keys[$i];

        }
        if (!
is_array($in)) {
            
$res['results'] = $results;
            return 
$res;
        }

        
$inlist implode(","$in);


        if (
$length_of_link_desc == 0) {
            
$fulltxt "fulltxt";
        } else {
            
$fulltxt "substring(fulltxt, 1, $length_of_link_desc)";
        }

        
$query1 "SELECT distinct link_id, url, title, description,  $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)";

        
$result mysql_query($query1);
        echo 
mysql_error();

        
$i 0;
        while (
$row mysql_fetch_row($result)) {
            
$res[$i]['title'] = $row[2];
            
$res[$i]['url'] = $row[1];
            if (
$row[3] != null && $show_meta_description == 1)
                
$res[$i]['fulltxt'] = $row[3];
            else 
                
$res[$i]['fulltxt'] = $row[4];
            
$res[$i]['size'] = $row[5];
            
$res[$i]['weight'] = $result_array[$row[0]];
            
$dom_result mysql_query("select domain from ".$mysql_table_prefix."domains where domain_id='".$domains[$row[0]]."'");
            
$dom_row mysql_fetch_row($dom_result);
            
$res[$i]['domain'] = $dom_row[0];
            
$i++;
        }



        if (
$merge_site_results  && $domain_qry == "") {
            
sort_with_domains($res);
        } else {
            
usort($res"cmp");     
        }
        echo 
mysql_error();
        
$res['maxweight'] = $maxweight;
        
$res['results'] = $results;
        return 
$res