我正在使用nutch 1.4和solr 3.3.0来爬网和索引我的网站。在前端,我使用PHP API Solarium查询Solr。我有以下字段默认情况下搜索:

content -> of type Text

title -> of type Text

ur-> of type url
.

我想搜索关键字,但同时我要根据一些URL模式排除一些结果,而不会影响结果总数返回。(例如,我一直想显示20个结果。)

如果有人知道与日光浴一起这样做的方式,那将是非常好的。但如果不是我很好奇,如何在solr中完成。

我已经看过面部搜索,但我无法缠绕它。如果有人可以详细解释,我真的很感激。

有帮助吗?

解决方案

我无法帮助您使用日光浴室,但您的solr查询应该相对简单:

q=+keyword -ur:exclude&rows=20
.

其他提示

http:// {url_endpoint} /?wt= json&rows= 20&start= 0&q=内容: contenttext 或标题: TITLETEXT 或UR: URL

  • wt= json结果将以json格式
  • Rows= 20个结果将由每页20个记录分名
  • start= 0页面开始显示结果
  • q=查询运行搜索(确保正确转义输入也*通配符以寻找之前和之后的任何内容) 使用卷曲的PHP中的

    $solr_end_point = '';   //enter endpoint
    $search_term = '';
    $url_type = '';
    $start = 0;
    $ch = curl_init();
    $query = urlencode("content:*{$search_term}* OR title:*{$search_term}* OR ur:*{$url_type}*");
    curl_setopt($ch, CURLOPT_URL, "http://{$solr_end_point}/?wt=json&rows=30&start={$start}&q={$query}");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 2);
    $result = curl_exec($ch);
    curl_close($ch);
    print_r($result);   //output result (json)
    $json_result = json_decode($result,true);
    print_r($json_result);  //output result as an array
    exit();
    
    .

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top