duanlan7239 2014-12-08 11:12
浏览 32
已采纳

狮身人面像搜索 - 按条件从结果中排除

Is there a way to execute search by some condition?

I saw there is SetFilter option, but it seems it's not what I need.

I would like to exclude all results, which have empty some column (e.g. company_title). But I don't see that I can define it like that using SetFilter (or I'm missing something)?

this is how it looks like atm:

$results = SphinxSearch::search($search, 'profiles')
                        ->setSelect('id')
                        ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_ALL)
                        ->limit(65, $skip);
  • 写回答

1条回答 默认 最新

  • douguo7431 2014-12-08 12:05
    关注

    Well you can't directly, because the sphinx index doesnt know which columns are empty (it indexes the text content, not the lack of content :)

    So you would have to create an attribute to store that fact

    sql_query = SELECT id, company_title, IF(company_title='',1,0) AS empty_title, ... 
    
    sql_attr_bool = empty_title
    

    Then you CAN use it with setFilter

    ->setFilter('empty_title',array(0));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?