@@ -19,7 +19,45 @@ public function testClassHierarchy()
19
19
unset($ facet );
20
20
}
21
21
22
- public function testTest ()
22
+ public function testQuery ()
23
+ {
24
+ $ client = $ this ->_getClient ();
25
+ $ index = $ client ->getIndex ('test ' );
26
+ $ index ->create (array (), true );
27
+ $ type = $ index ->getType ('helloworld ' );
28
+
29
+ $ mapping = new Mapping ($ type , array (
30
+ 'name ' => array ('type ' => 'string ' , 'store ' => 'no ' ),
31
+ 'dtmPosted ' => array ('type ' => 'date ' , 'store ' => 'no ' , 'format ' => 'yyyy-MM-dd HH:mm:ss ' ),
32
+ ));
33
+ $ type ->setMapping ($ mapping );
34
+
35
+ $ doc = new Document (1 , array ('name ' => 'nicolas ruflin ' , 'dtmPosted ' => "2011-06-23 21:53:00 " ));
36
+ $ type ->addDocument ($ doc );
37
+ $ doc = new Document (2 , array ('name ' => 'raul martinez jr ' , 'dtmPosted ' => "2011-06-23 09:53:00 " ));
38
+ $ type ->addDocument ($ doc );
39
+ $ doc = new Document (3 , array ('name ' => 'rachelle clemente ' , 'dtmPosted ' => "2011-07-08 08:53:00 " ));
40
+ $ type ->addDocument ($ doc );
41
+ $ doc = new Document (4 , array ('name ' => 'elastica search ' , 'dtmPosted ' => "2011-07-08 01:53:00 " ));
42
+ $ type ->addDocument ($ doc );
43
+
44
+ $ facet = new DateHistogram ('dateHist1 ' );
45
+ $ facet ->setInterval ("day " );
46
+ $ facet ->setField ("dtmPosted " );
47
+
48
+ $ query = new Query ();
49
+ $ query ->addFacet ($ facet );
50
+ $ query ->setQuery (new MatchAll ());
51
+ $ index ->refresh ();
52
+
53
+ $ response = $ type ->search ($ query );
54
+ $ facets = $ response ->getFacets ();
55
+
56
+ $ this ->assertEquals (4 , $ response ->getTotalHits ());
57
+ $ this ->assertEquals (2 , count ($ facets ['dateHist1 ' ]['entries ' ]));
58
+ }
59
+
60
+ public function testFactor ()
23
61
{
24
62
$ client = $ this ->_getClient ();
25
63
$ index = $ client ->getIndex ('test ' );
0 commit comments