首页 > 解决方案 > ElasticSearch 布尔查询到 Solrj 查询

问题描述

是否有任何工具或简单的技术可以将复杂的 ES 布尔查询迁移到 Solr/Solrj 查询。
我知道那种must => AND should => OR需要改变的。在此处查询示例 -

{
  "bool": {
    "must": [
      {
        "term": {
          "locale": {
            "value": "XXX",
            "boost": 1
          }
        }
      },
      {
        "terms": {
          "contentType": [
            "YYY",
            "ZZZ"
          ],
          "boost": 1
        }
      },
      {
        "terms": {
          "docId": [
            "ABC",
            "JKL"
          ],
          "boost": 1
        }
      },
      {
        "term": {
          "unPublished": {
            "value": false,
            "boost": 1
          }
        }
      }
    ],
    "disable_coord": false,
    "adjust_pure_negative": true,
    "boost": 1
  }
}

标签: elasticsearchsolrsolrjbooleanquery

解决方案


您可以使用JSON Query DSL 和复合查询

{
    "query": {
        "bool": {
            "must": [
                "title:solr",
                "content:(lucene solr)"
            ],
            "must_not": "{!frange u:3.0}ranking"
        }
    }
}

推荐阅读