Requests

  

PUT /_snapshot/backup
{
    "type": "fs",
    "settings": {
        "location": "/var/backups/elasticsearch/snapshot",
        "compress": true
    }
}

GET /_snapshot/_all?pretty"

PUT /_snapshot/backup/es_index_products/?wait_for_completion=true

PUT /_snapshot/backup/es_index_lot/?wait_for_completion=true
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "brand.id": 129
          }
        }
      ]
    }
  },
  "aggs": {
    "brands_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "brand.id"
      }
    },
    "lots_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "lots"
      }
    },
    "users_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "attributes.user_id"
      }
    }     
  }
}
GET /es_index_lots/lots/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "brand.id": 129
          }
        }
      ]
    }
  },
  "aggs": {
    "1_brand.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "brand.id"
      }
    }
  }
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        },
        {
          "terms": {
            "categories.id": "1"
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "categories"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "categories"
                      }
                    },
                    {
                      "term": {
                        "categories.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "brand"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "brand"
                      }
                    },
                    {
                      "term": {
                        "brand.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "model"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "model"
                      }
                    },
                    {
                      "term": {
                        "model.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "terms": {
            "product_collections": [
              "1"
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "66",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              },
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "71",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              },
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "73",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        },
        {
          "term": {
            "attributes.product_status_id": 1
          }
        }
      ]
    }
  },
  "aggs": {
    "0_categories.id_filter_agg": {
      "filter": {
        "terms": {
          "categories.id": "1"
        }
      },
      "aggs": {
        "categories.id_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "categories.id"
          }
        }
      }
    },
    "1_brand.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "brand.id"
      }
    },
    "2_model.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "model.id"
      }
    },
    "3_product_collections_filter_agg": {
      "filter": {
        "terms": {
          "product_collections": [
            "1"
          ]
        }
      },
      "aggs": {
        "product_collections_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "product_collections"
          }
        }
      }
    },
    "4_in_stock_terms_agg": {
      "terms": {
        "script": {
          "source": "doc['lots'].values.size() > 0",
          "lang": "painless"
        },
        "size": 10000
      }
    },
    "5_string_facet_nested_agg": {
      "nested": {
        "path": "string_facet"
      },
      "aggs": {
        "string_facet.facet_name_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "string_facet.facet_name"
          },
          "aggs": {
            "string_facet.facet_value_terms_agg": {
              "terms": {
                "size": 10000,
                "field": "string_facet.facet_value"
              }
            }
          }
        }
      }
    }
  },
  "min_score": 0.5,
  "_source": false
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "53",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  },
  "_source": false
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "script": {
            "script": {
              "source": "doc['attributes.id'].value == params.id",
              "params": {
                "id": 1
              },
              "lang": "painless"
            }
          }
        },
        {
          "script": {
            "script": {
              "source": "doc['attributes.cat_id'].value == params.cat_id",
              "params": {
                "cat_id": 1
              },
              "lang": "painless"
            }
          }
        }
      ]
    }
  }
}
GET /es_index_products/products/_search
{
  "body": {
    "bool": {
      "must": [
        {
          "script": {
            "script": {
              "source": "doc['attributes.id'].value == params.id",
              "lang": "painless",
              "params": {
                "id": 1
              }
            }
          }
        },
        {
          "script": {
            "script": {
              "source": "doc['attributes.updated_at'].value == params.updated_at",
              "lang": "painless",
              "params": {
                "updated_at": "2016-06-15 08:47:53"
              }
            }
          }
        }
      ]
    }
  }
}
GET /es_index_products/products/_search
{
  "query": {
    "script": {
      "script": {
        "source": "(doc['attributes.id'].value == params.id) && (doc['attributes.cat_id'].value == params.cat_id)",
        "lang": "painless",
        "params": {
          "id": 7609,
          "cat_id": 1
        }
      }
    }
  }
}
GET /es_index_lots/lots/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "product_id": "102"
          }
        }
      ]
    }
  }
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "categories"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "categories"
                      }
                    },
                    {
                      "term": {
                        "categories.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "brand"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "brand"
                      }
                    },
                    {
                      "term": {
                        "brand.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "model"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "model"
                      }
                    },
                    {
                      "term": {
                        "model.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "term": {
            "product_status_id": 1
          }
        }
      ],
      "must": [
        {
          "match_all": {}
        }
      ]
    }
  },
  "aggs": {
    "0_categories.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "categories.id"
      }
    },
    "1_brand.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "brand.id"
      }
    },
    "2_model.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "model.id"
      }
    },
    "3_product_collections_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "product_collections"
      }
    },
    "4_in_stock_terms_agg": {
      "terms": {
        "script": {
          "source": "doc.lots.values.size() > 0",
          "lang": "painless"
        },
        "size": 10000
      }
    },
    "5_string_facet_nested_agg": {
      "nested": {
        "path": "string_facet"
      },
      "aggs": {
        "string_facet.facet_name_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "string_facet.facet_name"
          },
          "aggs": {
            "string_facet.facet_value_terms_agg": {
              "terms": {
                "size": 10000,
                "field": "string_facet.facet_value"
              }
            }
          }
        }
      }
    }
  },
  "_source": true
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "categories"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "categories"
                      }
                    },
                    {
                      "term": {
                        "categories.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "brand"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "brand"
                      }
                    },
                    {
                      "term": {
                        "brand.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "model"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "model"
                      }
                    },
                    {
                      "term": {
                        "model.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "53",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        },
        {
          "term": {
            "product_status_id": 1
          }
        }
      ],
      "must": [
        {
          "match_all": {}
        },
        {
          "terms": {
            "categories.id": [
              "1"
            ]
          }
        }
      ]
    }
  },
  "aggs": {
    "0_categories.id_filter_agg": {
      "filter": {
        "terms": {
          "categories.id": [
            "1"
          ]
        }
      },
      "aggs": {
        "categories.id_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "categories.id"
          }
        }
      }
    },
    "1_brand.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "brand.id"
      }
    },
    "2_model.id_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "model.id"
      }
    },
    "3_product_collections_terms_agg": {
      "terms": {
        "size": 10000,
        "field": "product_collections"
      }
    },
    "4_in_stock_terms_agg": {
      "terms": {
        "script": {
          "source": "doc.lots.values.size() > 0",
          "lang": "painless"
        },
        "size": 10000
      }
    },
    "5_string_facet_nested_agg": {
      "nested": {
        "path": "string_facet"
      },
      "aggs": {
        "string_facet.facet_name_terms_agg": {
          "terms": {
            "size": 10000,
            "field": "string_facet.facet_name"
          },
          "aggs": {
            "string_facet.facet_value_terms_agg": {
              "terms": {
                "size": 10000,
                "field": "string_facet.facet_value"
              }
            }
          }
        }
      }
    }
  },
  "_source": false
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "categories"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "categories"
                      }
                    },
                    {
                      "term": {
                        "categories.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "brand"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "brand"
                      }
                    },
                    {
                      "term": {
                        "brand.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "model"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "model"
                      }
                    },
                    {
                      "term": {
                        "model.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "nested": {
                  "path": "string_facet",
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "string_facet.facet_name": {
                              "value": "diameter",
                              "boost": 1
                            }
                          }
                        },
                        {
                          "term": {
                            "string_facet.facet_value": {
                              "value": "53",
                              "boost": 1
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        },
        {
          "term": {
            "product_status_id": 1
          }
        }
      ],
      "must": [
        {
          "match_all": {}
        }
      ]
    }
  },
  "_source": false
}
GET _search
{
  "query": {
    "match_all": {}
  }
}
GET /es_index_products/products/_search
{
  "query": {
    "match_all": {}
  }
}
GET /es_index_lots/lots/_search
{
  "query": {
    "match_all": {}
  }
}
GET /es_index_products/products/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "categories"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "categories"
                      }
                    },
                    {
                      "term": {
                        "categories.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "brand"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "brand"
                      }
                    },
                    {
                      "term": {
                        "brand.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must_not": {
                    "exists": {
                      "field": "model"
                    }
                  }
                }
              },
              {
                "bool": {
                  "must": [
                    {
                      "exists": {
                        "field": "model"
                      }
                    },
                    {
                      "term": {
                        "model.enabled": 1
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "term": {
            "product_status_id": 1
          }
        },
        {
          "script": {
            "script": {
              "source": "doc.product_collections.values.size() > 0",
              "lang": "painless"
            }
          }
        }
      ],
      "must": [
        {
          "bool": {
            "should": [
              {
                "multi_match": {
                  "query": "rolex",
                  "type": "cross_fields",
                  "fields": [
                    "product_model_ref^100",
                    "model.name^30",
                    "brand.name^15",
                    "brand.aliases^15",
                    "categories.name^20"
                  ],
                  "operator": "and",
                  "boost": 1
                }
              },
              {
                "multi_match": {
                  "query": "rolex",
                  "type": "cross_fields",
                  "fields": [
                    "product_model_ref^100",
                    "model.name^30",
                    "brand.name^15",
                    "brand.aliases^15",
                    "categories.name^20"
                  ],
                  "operator": "and",
                  "boost": 1
                }
              },
              {
                "multi_match": {
                  "query": "rolex",
                  "type": "cross_fields",
                  "fields": [
                    "product_model_ref^100",
                    "model.name^30",
                    "brand.name^15",
                    "brand.aliases^15",
                    "categories.name^20"
                  ],
                  "operator": "and",
                  "boost": 1
                }
              }
            ]
          }
        }
      ]
    }
  },
  "size": 1,
  "_source": "*",
  "sort": [
    {
      "_uid": {
        "order": "asc"
      }
    }
  ]
}
POST /yii-log/_search
{
  "query": {
    "match": {
      "category": {
        "query": "Error",
        "type": "phrase"
      }
    }
  },
  "size": 10,
  "_source": "message",
  "sort": [
    {
      "_uid": {
        "order": "asc"
      }
    }
  ]  
}
POST /yii-log/_search
{
  "query": {
    "match": {
      "category": {
        "query": "yii\\debug\\Module::checkAccess",
        "type": "phrase"
      }
    }
  },
  "size": 1,
  "_source": "*",
  "sort": [
    {
      "_uid": {
        "order": "asc"
      }
    }
  ]  
}
POST /yii-log/_search
{
  "query": {
    "match": {
      "category": {
        "query": "yii\\web\\HttpException:404",
        "type": "phrase"
      }
    }
  },
  "size": 1,
  "_source": "*",
  "sort": [
    {
      "_uid": {
        "order": "asc"
      }
    }
  ]  
}