コード例 #1
0
 /**
  * Tests span near query for expected search result.
  */
 public function testSpanNearQueryWhenSlopIsLarge()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $spanNear = new SpanNearQuery(['in_order' => true]);
     $spanNear->setSlop(40);
     $spanNear->addQuery(new SpanTermQuery('description', 'one'))->addQuery(new SpanTermQuery('description', 'two'))->addQuery(new SpanTermQuery('description', 'six'));
     $search = $repo->createSearch()->addQuery($spanNear);
     $results = $repo->execute($search, Repository::RESULTS_ARRAY);
     $this->assertEquals(1, count($results));
 }
コード例 #2
0
 /**
  * Test Span not query.
  */
 public function testSpanNotTestSimpleSpanQueries()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $spanNear = new SpanNearQuery();
     $spanNear->addQuery(new SpanTermQuery('description', 'consectetur'))->setSlop(1);
     $spanNot = new SpanNotQuery(new SpanTermQuery('description', 'foo'), $spanNear);
     $search = $repo->createSearch()->addQuery($spanNot);
     $results = $repo->execute($search, Repository::RESULTS_ARRAY);
     $this->assertEquals(1, count($results));
 }
コード例 #3
0
 /**
  * Test Span or query with different span queries.
  */
 public function testSpanOrQuery()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $spanNear = new SpanNearQuery(['in_order' => true]);
     $spanNear->setSlop(1);
     $spanNear->addQuery(new SpanTermQuery('description', 'ipsum'))->addQuery(new SpanTermQuery('description', 'sit'));
     $spanOr = new SpanOrQuery();
     $spanOr->addQuery(new SpanFirstQuery(new SpanTermQuery('description', 'ipsum'), 2))->addQuery($spanNear);
     $search = $repo->createSearch()->addQuery($spanOr);
     $results = $repo->execute($search, Repository::RESULTS_ARRAY);
     $this->assertEquals(2, count($results));
 }
コード例 #4
0
 /**
  * Tests get Type method.
  */
 public function testSpanNearQueryGetType()
 {
     $query = new SpanNearQuery(['name']);
     $result = $query->getType();
     $this->assertEquals('span_near', $result);
 }