douli8040 2011-04-19 16:03
浏览 59
已采纳

SphinxAPI SetFilter为false

I have sphinx installed for my search engine, and it works great, but now I'm trying to add a few extra features to the search using setFilter() which should allow me to do WHERE/AND clauses, but whenever I try a search, it returns no results when there should.

This is my MySQL Code : http://pastebin.com/gFrvKumW

This is my sphinx.conf : http://pastebin.com/XdppZ0MG

And my PHP code :

<?php
    require("sphinxapi.php");
    $cl = new SphinxClient();
    $host = "localhost";
    $port = 9312;
    $index = "library";
    $q = "livres";
    $limit = 20;
    $ranker = SPH_RANK_PROXIMITY_BM25;
    $mode = SPH_MATCH_ALL;
    $cl->SetServer($host, $port);
    $cl->SetConnectTimeout(0);
    $cl->SetMatchMode($mode);
    $cl->SetRankingMode($ranker);
    //$cl->SetFilter('author_id', array(1));
    $res = $cl->Query($q, $index);
    die(var_dump($res));
?>

if you add the commented line is not working anymore. I do not understand why

  • 写回答

1条回答 默认 最新

  • dpn68721 2011-04-19 16:11
    关注

    if you want to be able to use a field as a filter, you'll need to add it in the sql_attr on your sphinx config file so if you want to filter by autor id, you'll need to add (assuming that the author's id is an integer):

    sql_query = SELECT `autors`.id, `books`.id, `books`.author_id, `books`.title, `books`.type, `authors`.name FROM `books`, `authors` WHERE `books`.author_id = `authors`.id
    sql_attr_uint = autor_id
    

    i hope this helps, Good Luck

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog