dongzhe3171 2017-08-14 20:43
浏览 49
已采纳

AND OR查询弹性搜索

I need to dynamically make elastic search query based on AND, OR query.

User inputs a string similar to SQL format:

((("query1 query2" OR query3) OR query4) AND (query5 OR query6)) AND query7

I parse it to array:

[
    'AND' => [
        [
            'AND' => [
                [
                    'OR' => [
                        [
                            'OR' => [
                                '" query1 query 2"',
                                'query3'
                            ]
                        ],
                        'query4'
                    ]
                ],
                [
                    'OR' => [
                        'query5',
                        'query6'
                    ]
                ]
            ]

        ],
        'query7'
    ]

]

And based on this array I need to make a search for one field.

Something like:

{"bool":{"must":[{"match":{"title":"research"}},{"match":{"title":"lecturer"}}]}}

But I'm stuck with nested conditions. Please advise.

  • 写回答

2条回答 默认 最新

  • douwei9759 2017-08-21 20:44
    关注

    I've created a small library out of it SqlElasticSearchQueryConverter

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 求用matlab求解上述微分方程的程序代码
  • ¥15 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致