How can I sort String with has_parent in ElasticSearch

Hello,
I created parent-child in ElasticSearch.

I use has_parent for query data, but I want to sort this data follow some parent field which is a String.

I tried to find solutions, I found how to sort in ElasticSearch documents

"query": {
        "has_parent" : {
            "parent_type" : "blog",
            "score" : true,
            "query" : {
                "function_score" : {
                    "script_score": {
                        "script": "_score * doc['view_count'].value"
                    }
                }
            }
        }
    }

https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-has-parent-query.html#_sorting_2

It use "score" * doc['view_count'] for searching which is an integer, but I want to do some calculations with String for searching it (with Groovy), but I don't know what should I do.

If you have another idea, please tell me.

thanks for helping me.

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