insomniac
insomniac

Reputation: 155

ElasticSearch boolean query to Solrj query

is there any tool or easy technique to migrate complex ES boolean query to Solr/ Solrj query.
I know kind of that must => AND should => OR needs to be changed. Query sample here -

{
  "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
  }
}

Upvotes: 1

Views: 134

Answers (1)

Alexandre Rafalovitch
Alexandre Rafalovitch

Reputation: 9789

You can use JSON Query DSL and compound queries.

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

Upvotes: 1

Related Questions