File tree 1 file changed +29
-0
lines changed 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -47,3 +47,32 @@ matching parent document. The score mode can be specified with the
47
47
}
48
48
}
49
49
--------------------------------------------------
50
+
51
+ [float]
52
+ ==== Sorting
53
+
54
+ Child documents can't be sorted by fields in matching parent documents via the
55
+ regular sort options. If you need to sort child documents by field in the parent
56
+ documents then you can should use the `function_score` query and then just sort
57
+ by `_score`.
58
+
59
+ Sorting tags by parent document' `view_count` field:
60
+
61
+ [source,js]
62
+ --------------------------------------------------
63
+ {
64
+ "query": {
65
+ "has_parent" : {
66
+ "parent_type" : "blog",
67
+ "score_mode" : "score",
68
+ "query" : {
69
+ "function_score" : {
70
+ "script_score": {
71
+ "script": "_score * doc['view_count'].value"
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ --------------------------------------------------
You can’t perform that action at this time.
0 commit comments