Exemplo n.º 1
0
 /**
  * More like this query based on the given object
  *
  * The id in the given object has to be set
  *
  * @param  \Elastica\Document           $doc    Document to query for similar objects
  * @param  array                        $params OPTIONAL Additional arguments for the query
  * @param  string|array|\Elastica\Query $query  OPTIONAL Query to filter the moreLikeThis results
  * @return \Elastica\ResultSet          ResultSet with all results inside
  * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-more-like-this.html
  */
 public function moreLikeThis(Document $doc, $params = array(), $query = array())
 {
     $path = $doc->getId() . '/_mlt';
     $query = Query::create($query);
     $response = $this->request($path, Request::GET, $query->toArray(), $params);
     return ResultSet::create($response, $query);
 }
 /**
  * @param mixed $query
  * @param $fullResult (default = false) By default only the total hit count is returned. If set to true, the full ResultSet including aggregations is returned.
  *
  * @return int|ResultSet
  */
 public function count($query = '', $fullResult = false)
 {
     $this->setOptionsAndQuery(null, $query);
     $query = $this->getQuery();
     $path = $this->getPath();
     $response = $this->getClient()->request($path, Request::GET, $query->toArray(), array(self::OPTION_SEARCH_TYPE => self::OPTION_SEARCH_TYPE_COUNT));
     $resultSet = ResultSet::create($response, $query);
     return $fullResult ? $resultSet : $resultSet->getTotalHits();
 }