# How to query type has array field's length \> 0

**URL:** <https://discuss.elastic.co/t/how-to-query-type-has-array-fields-length-0/18347>\
**Category:** Elasticsearch\
**Created:** [June 26, 2014, 7:48am UTC](https://discuss.elastic.co/t/how-to-query-type-has-array-fields-length-0/18347 "2014-06-26T07:48:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hoan\_Nguyen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoan_nguyen/32/1458_2.png) [@Hoan\_Nguyen](https://discuss.elastic.co/u/Hoan_Nguyen)\
**Post date:** [June 26, 2014, 7:48am UTC](https://discuss.elastic.co/t/how-to-query-type-has-array-fields-length-0/18347/1 "2014-06-26T07:48:54Z")

</div>

Hi,

Here is school entity mapping

school:  
mappings:  
name: ~  
rankings: ~

Here is my query:

Array  
(  
[sort] =\> Array  
(  
[rankingTotal] =\> Array  
(  
[order] =\> asc  
)

```
    )

[query] => Array
    (
        [bool] => Array
            (
                [must] => Array
                    (
                        [0] => Array
                            (
                                [fuzzy_like_this] => Array
                                    (
                                        [fields] => Array
                                            (
                                                [0] => name
                                                [1] => shortName
                                                [2] => city
                                                [3] => address
                                            )

                                        [boost] => 1
                                        [like_text] => hanoi
                                        [min_similarity] => 1
                                        [prefix_length] => 0
                                        [ignore_tf] => 
                                        [max_query_terms] => 25
                                    )

                            )

                    )

            )

    )

[filter] => Array
    (
        [bool] => Array
            (
                [must] => Array
                    (
                        [0] => Array
                            (
                                [script] => Array
                                    (
                                        [script] => doc['accreditations'].values.length > 0
                                    )

                            )

                        [1] => Array
                            (
                                [script] => Array
                                    (
                                        [script] => doc['rankings'].values.length > 0
                                    )

                            )

                    )

            )

    )

```

)

I get a problem with query for finding all school contains rankings element  
length \> 0. I try use filter script but it throws error. I don't know how  
to fix it. Pls help me resolve this issue. Thanks.

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c413c043-0684-4b7d-bfc6-91ec24a5d72c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c413c043-0684-4b7d-bfc6-91ec24a5d72c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:19am UTC](https://discuss.elastic.co/t/how-to-query-type-has-array-fields-length-0/18347/2 "2017-07-06T01:19:36Z")

</div>


