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 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型
  • ¥15 Python 如何安装 distutils模块
  • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行
  • ¥15 资源泄露软件闪退怎么解决?