Es JOIN DATA TYPE AGGRETION


(Fırat) #1

Hi heros,
I used join data type and its my query.

{
  "size": 0, 
  "query": {
    "has_child": {
      "type": "variation",
      "query": {
        "bool": {
          "must_not": [
            {
            "match": {
              "stock": 0
            }
          }
        ]
      }
    }
  }
  },
  "aggs": {
    "sizes": {
      "terms": {
        "field": "size.keyword",
        "size": 10
      },
      "aggs": {
        "to-product": {
          "children": {
            "type" : "product" 
          },
          "aggs": {
            "top-names": {
              "terms": {
                "field": "name.keyword",
                "size": 10
              }
            }
          }
        }
      }
   
    }
  }
}

My problem is aggretion give me all sizes but i need only in stock sizes from query response.
(query working true.)

Example Product

PUT products/prod/2?refresh
{
  "name": "Koton Kazak",
  "my_join_field":  "product" 
}

PUT products/prod/10?routing=2&refresh 
{
  "size": "xxl",
  "color": "blau",
  "stock":7,
  "my_join_field": {
    "name": "variation", 
    "parent": "2" 
  }
}

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.