示例#1
0
 function testRangeBucketConstraint()
 {
     parent::$logger->debug('testRangeBucketConstraint');
     $options3 = new MLPHP\Options(parent::$client);
     $constraint3 = new MLPHP\RangeConstraint('myConstr3', 'string', 'true', 'foo');
     $buck1 = new MLPHP\Bucket('low', array('lt' => 10));
     $buck2 = new MLPHP\Bucket('high', array('ge' => 10, 'lt' => 20));
     $constraint3->addBuckets(array($buck1, $buck2));
     $options3->addConstraint($constraint3);
     $this->assertXmlStringEqualsXmlString('
         <options xmlns="http://marklogic.com/appservices/search">
           <constraint name="myConstr3">
            <range type="string" facet="true">
                 <element ns="" name="foo"/>
                 <bucket name="low" lt="10" />
                 <bucket name="high" ge="10" lt="20" />
            </range>
           </constraint>
         </options>
     ', $options3->getAsXML());
 }
示例#2
0
 function testRangeBucket()
 {
     parent::$logger->debug('testBucketConstraint');
     $options = new MLPHP\Options(parent::$client, 'testBucketConstraint');
     $constraint = new MLPHP\RangeConstraint('myBucket', 'xs:int', 'true', 'bill', '', 'number');
     $buck1 = new MLPHP\Bucket('low', array('lt' => 1000));
     $buck2 = new MLPHP\Bucket('high', array('ge' => 1000, 'lt' => 2000));
     $constraint->addBuckets(array($buck1, $buck2));
     $options->addConstraint($constraint)->write();
     $search = new MLPHP\Search(parent::$client, 1, 3);
     $results = $search->setDirectory('/bills')->retrieve('myBucket:high', array('options' => 'testBucketConstraint'));
     $this->assertEquals(4, $results->getTotal());
 }