du5739 2014-12-13 04:50
浏览 66
已采纳

Sphinx Wordpress插件通过自定义meta_key缩小结果

I'm trying to show the results only for posts which has a custom meta_key "my_metakey", the filed also should not be empty.

I've tried to modify the sql_query inside the sphinx.conf file with no luck.

I'm not familiar with the way sphinx uses the sphinx.conf file, so not sure how many edits are required to achieve this.

The plugin I'm using is https://wordpress.org/plugins/wordpress-sphinx-plugin/

Any help is highly appropriated!

  • 写回答

1条回答 默认 最新

  • dsmgcse8876 2015-01-04 10:40
    关注

    After lots of testing I've accomplished what I was looking for by modifying the SQL query of source {prefix}main_posts{} inside the sphinx.conf file as the following:

    sql_query        = select \
            p.ID*2+1 as ID, \
            0 as comment_ID,\
            p.ID as post_ID,\
            p.post_title as title, \
            p.post_content as body, \
            t.name as category, \
            my_metakey_meta.meta_value as my_metakey, \
            .
            .
            .
        from \
            {wp_posts} as p \
        left join \
            {wp_term_relationships} tr on (p.ID = tr.object_id) \
            .
            .
        left join \
            wp_postmeta my_metakey_meta on (p.ID = my_metakey_meta.post_id and my_metakey_meta.meta_key = 'my_metakey') \
            .
            .
            .
        where \
            p.id>=$start AND p.id<=$end and \
            p.post_status = 'publish' and \
            my_metakey_meta.meta_value != '' \
            group by p.ID
    

    And modified the SQL query of source {prefix}main_comments{} as the following:

    sql_query        = select \
            .
            .
            '' as category, \
            '' as my_metakey, \
            .
            .
            .
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥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,如何解決?