Query inside a filter?


(Vicente de Rivera III) #1

Below is the json passed into elasticsearch js client.

  1. Is the query_string treated as query here? How do I declare it as a filter?
  2. How come this works given that my top element is filter?
    {
      "index": "index",
      "sort": [
        "shop.chaosEquiv:asc"
      ],
      "from": 0,
      "size": 50,
      "body": {
        "filter": {
          "query": {
            "query_string": {
              "default_operator": "AND",
              "query": "info.name:\"Sire of Shards\" attributes.league:\"Perandus\" shop.hasPrice:true shop.verified:YES"
            }
          }
        }
      }
    }

(Vicente de Rivera III) #2

Ended up with:

  "body": {
    "query": {
      "filtered": {
        "filter": {
          "bool": {
            "must": {
              "query_string": {
                "default_operator": "AND",
                "query": "attributes.itemType:Boots modsPseudo.+#%\\ Total\\ to\\ Fire\\ Resistance:[40 TO *] attributes.league:\"Perandus\" shop.hasPrice:true shop.verified:YES"
              }
            }
          }
        }
      }
    }
  }

(system) #3