equal
deleted
inserted
replaced
6 { |
6 { |
7 $query = [ |
7 $query = [ |
8 'index' => env('ELASTICSEARCH_INDEX'), |
8 'index' => env('ELASTICSEARCH_INDEX'), |
9 'body' => [ |
9 'body' => [ |
10 "size" => 0, |
10 "size" => 0, |
|
11 "query" => [ |
|
12 'match_all' => [] |
|
13 ], |
11 "aggs" => [ |
14 "aggs" => [ |
12 "geos" => [ |
15 "geos" => [ |
13 "terms" => [ |
16 "terms" => [ |
14 "size" => 0, |
17 "size" => 0, |
15 "field" => "geonames_hierarchy" |
18 "field" => "geonames_hierarchy" |
58 '6255148' => 2684, |
61 '6255148' => 2684, |
59 '3017382' => 2674, |
62 '3017382' => 2674, |
60 '3027939' => 851 |
63 '3027939' => 851 |
61 ]]); |
64 ]]); |
62 } |
65 } |
|
66 |
|
67 |
|
68 public function testGetIndexEarth() |
|
69 { |
|
70 $query = [ |
|
71 'index' => env('ELASTICSEARCH_INDEX'), |
|
72 'body' => [ |
|
73 "size" => 0, |
|
74 "query" => [ |
|
75 'match_all' => [] |
|
76 ], |
|
77 "aggs" => [ |
|
78 "geos" => [ |
|
79 "terms" => [ |
|
80 "size" => 0, |
|
81 "field" => "geonames_hierarchy" |
|
82 ] |
|
83 ] |
|
84 ] |
|
85 ] |
|
86 ]; |
|
87 |
|
88 Es::shouldReceive('search') |
|
89 ->once() |
|
90 ->with($query) |
|
91 ->andReturn(json_decode("{ |
|
92 \"took\" : 17, |
|
93 \"timed_out\" : false, |
|
94 \"_shards\" : { |
|
95 \"total\" : 1, |
|
96 \"successful\" : 1, |
|
97 \"failed\" : 0 |
|
98 }, |
|
99 \"hits\" : { |
|
100 \"total\" : 3011, |
|
101 \"max_score\" : 0.0, |
|
102 \"hits\" : [ ] |
|
103 }, |
|
104 \"aggregations\" : { |
|
105 \"geos\" : { |
|
106 \"doc_count_error_upper_bound\" : 0, |
|
107 \"sum_other_doc_count\" : 0, |
|
108 \"buckets\" : [] |
|
109 } |
|
110 } |
|
111 }", true)); |
|
112 |
|
113 $this->get('/api/v1/stats/geostats/?area='.config('corpusparole.geonames_earth_geonamesid'))->assertTrue($this->response->isOk(), $this->response->content()); |
|
114 } |
|
115 |
|
116 |
|
117 public function testGetIndexArea() |
|
118 { |
|
119 $query = [ |
|
120 'index' => env('ELASTICSEARCH_INDEX'), |
|
121 'body' => [ |
|
122 "size" => 0, |
|
123 "query" => [ |
|
124 'term' => [ |
|
125 "geonames_hierarchy" => "code_area" |
|
126 ] |
|
127 ], |
|
128 "aggs" => [ |
|
129 "geos" => [ |
|
130 "terms" => [ |
|
131 "size" => 0, |
|
132 "field" => "geonames_hierarchy" |
|
133 ] |
|
134 ] |
|
135 ] |
|
136 ] |
|
137 ]; |
|
138 |
|
139 Es::shouldReceive('search') |
|
140 ->once() |
|
141 ->with($query) |
|
142 ->andReturn(json_decode("{ |
|
143 \"took\" : 17, |
|
144 \"timed_out\" : false, |
|
145 \"_shards\" : { |
|
146 \"total\" : 1, |
|
147 \"successful\" : 1, |
|
148 \"failed\" : 0 |
|
149 }, |
|
150 \"hits\" : { |
|
151 \"total\" : 3011, |
|
152 \"max_score\" : 0.0, |
|
153 \"hits\" : [ ] |
|
154 }, |
|
155 \"aggregations\" : { |
|
156 \"geos\" : { |
|
157 \"doc_count_error_upper_bound\" : 0, |
|
158 \"sum_other_doc_count\" : 0, |
|
159 \"buckets\" : [] |
|
160 } |
|
161 } |
|
162 }", true)); |
|
163 |
|
164 $this->get('/api/v1/stats/geostats/?area=code_area')->assertTrue($this->response->isOk(), $this->response->content()); |
|
165 } |
|
166 |
63 } |
167 } |