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


(Hoan Nguyen) #1

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


(system) #2