Has_child filter and min_children

I have ES 1.3.4 installed and i am trying to use a filter on has child, but
I keep getting the error "[has_child] filter does not support
[min_children]"

Even though the documents
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html specifically
show it...

The has_child filter allows you to specify that a minimum and/or maximum
number of children are required to match for the parent doc to be
considered a match:

{
"has_child" : {
"type" : "comment",
"min_children": 2, http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html#CO49-2
"max_children": 10, http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html#CO49-3
"filter" : {
"term" : {
"user" : "john"
}
}
}
}

Any help I can get on this would be greatly appreciated!

{
"query": {

  "filtered": {
     "query": {
        "match_all": {}
     },
     "filter": {
        "and": [
            {
            "has_child":{
                "type":"service",
                "min_children":2,
                "filter":{"match_all": {}}
            }
            },
           {
              "term": {
                 "ismd": true
              }
           },
           {
              "terms": {
                 "owk": [
                    23621
                 ]
              }
           },
           {
              "terms": {
                 "oowk": [
                    23621
                 ]
              }
           },
           {
              "term": {
                 "ipl": false
              }
           },
           {
              "terms": {
                 "pwk": [
                    21754
                 ]
              }
           },
           {
              "term": {
                 "isb": false
              }
           }
        ]
     }
  }

},
"from": 0,
"size": 0,
"aggs": {

  "unique": {
     
     "cardinality": {
        "field": "hhk",
        "precision_threshold": 40000
     }
  }

}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fa54ac23-cb19-4a58-9192-d50cc5476d05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ANy thoughts anyone?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6c97ec75-8c4e-44a3-92e2-1a54c8317e86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I've come up with something that will allow me to get the minimun level...
Now, do I need to do this at the client level to get the 'max' number...
say I want a range between 5 and 10... how do I limit the results to n
number of children?

{
"min_score": 5,
"query": {
"filtered": {
"query": {
"has_child": {
"type": "service",
"score_type": "total",
"query": {
"match_all": {}
}
}
},
"filter": {
"and": [
{
"terms": {
"owk": [
23621
]
}
},
{
"terms": {
"oowk": [
23621
]
}
},
{
"term": {
"ismd": true
}
},
{
"and": [
{
"terms": {
"owk": [
23621
]
}
},
{
"terms": {
"oowk": [
23621
]
}
},
{
"term": {
"ipl": false
}
},
{
"terms": {
"pwk": [
21754
]
}
},
{
"range": {
"my": {
"gte": 1980,
"lte": 2015
}
}
},
{
"term": {
"isb": false
}
}
]
}
]
}
}
},
"from": 0,
"size": 0,
"aggs": {
"unique": {
"cardinality": {
"field": "hhk",
"precision_threshold": 40000
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5539c864-c50c-4ded-8077-bcef3d87deeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I guess if I bang at it hard enough.. I'll find a solution... this
'Appears' to work... :slight_smile:

{

"min_score": 0,

"query": {

  "function_score": {

     "boost_mode": "multiply",

     "functions": [

        {

           "script_score": {

              "params": {

                 "min_value":0,

                 "max_value": 5

              },

              "script": "_score <= max_value && _score >= 

min_value?1:-1"

           }

        }

     ],

     "query": {

        "filtered": {

           "query": {

              "has_child": {

                 "type": "service",

                 "score_type": "total",

                 "query": {

                    "match_all": {}

                 }

              }

           },

           "filter": {

              "and": [

                 {

                    "terms": {

                       "owk": [

                          23621

                       ]

                    }

                 },

                 {

                    "terms": {

                       "oowk": [

                          23621

                       ]

                    }

                 },

                 {

                    "term": {

                       "ismd": true

                    }

                 },

                 {

                    "and": [

                       {

                          "terms": {

                             "owk": [

                                23621

                             ]

                          }

                       },

                       {

                          "terms": {

                             "oowk": [

                                23621

                             ]

                          }

                       },

                       {

                          "term": {

                             "ipl": false

                          }

                       },

                       {

                          "terms": {

                             "pwk": [

                                21754

                             ]

                          }

                       },

                       {

                          "range": {

                             "my": {

                                "gte": 1980,

                                "lte": 2015

                             }

                          }

                       },

                       {

                          "term": {

                             "isb": false

                          }

                       }

                    ]

                 }

              ]

           }

        }

     }

  }

},

"from": 0,

"size": 0,

"aggs": {

  "unique": {

     "cardinality": {

        "field": "hhk",

        "precision_threshold": 40000

     }

  }

}

}

On Wednesday, October 15, 2014 8:50:24 AM UTC-4, Darren McDaniel wrote:

I've come up with something that will allow me to get the minimun level...
Now, do I need to do this at the client level to get the 'max' number...
say I want a range between 5 and 10... how do I limit the results to n
number of children?

{
"min_score": 5,
"query": {
"filtered": {
"query": {
"has_child": {
"type": "service",
"score_type": "total",
"query": {
"match_all": {}
}
}
},
"filter": {
"and": [
{
"terms": {
"owk": [
23621
]
}
},
{
"terms": {
"oowk": [
23621
]
}
},
{
"term": {
"ismd": true
}
},
{
"and": [
{
"terms": {
"owk": [
23621
]
}
},
{
"terms": {
"oowk": [
23621
]
}
},
{
"term": {
"ipl": false
}
},
{
"terms": {
"pwk": [
21754
]
}
},
{
"range": {
"my": {
"gte": 1980,
"lte": 2015
}
}
},
{
"term": {
"isb": false
}
}
]
}
]
}
}
},
"from": 0,
"size": 0,
"aggs": {
"unique": {
"cardinality": {
"field": "hhk",
"precision_threshold": 40000
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5a4c4564-a582-424b-aa8f-d59e9e1474ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.