Day 17: Elastic’s elastic!

Some discussions regarding elastic

1 min read    19 May 2017    

elasticsearch

  • How are filtered and filter different ? filtered is use to pass multiple query parameters.

But why use filter or filters when my query works just fine ?

query ranks the indices, which takes up some computation time. If we’re interested only in the indices, and not how good the match is, we prefer filter.

The ping here is great [10 - 15 ms for 90% of the time]. Unfortunately, none of us are hard core gamers to utilise this ping.

Wow, so many ways to execute the same query. I know atleast 5.

1.

GET orders/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query": {
            "match_all": {}
          }
        },
        {
          "terms": {
            "seller._id": ["some_demo_id"]
          }
        }
      ]
    }
  }
}

2.

GET orders/_search
{
  "sort": [
    { "created_on" : {"order" : "desc"}}
  ],
  "query": {
    "bool": {
      "filter": [
        {"term": {"seller_id": "some_demo_id"} }
      ]
    }
  }
}

3.

GET orders/_search
{
  "sort": [
    { "created_on" : {"order" : "desc"}}
  ],
  "query": {
    "constant_score": {
      "filter": {
        "term":
        {
          "seller_id": "some_demo_id"
        }
      }
    }
  }
}

4.

GET orders/_search
{
  "sort": [
    { "created_on" : {"order" : "desc"}}
  ],
  "query": {
    "constant_score": {
      "filter": {
        "term":
        {
          "seller_id": "some_demo_id"
        }
      }
    }
  }
}

5.

GET orders/_search
{
  "sort": [
    { "created_on" : {"order" : "desc"}}
  ],
  "query": {
    "filtered": {
      "filter": {
        "term": { "seller_id": "some_demo_id" }
      }
    }
  }
}

Possibly launch own jekyll theme.

Some rights reserved.

Leave a Comment