summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-10-18 09:31:31 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-10-18 09:31:31 +0200
commit80f7dc77d430774192b929d780f96260066df2ee (patch)
tree102eaae7fc9ec567f2af76e96da3de2d1e83afcf /vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
parentcccd7bb4d819334c07e0dadaf16cbfdef31880e1 (diff)
Update to MediaWiki 1.25.3
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Multi/Search.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Multi/Search.php198
1 files changed, 0 insertions, 198 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php b/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
deleted file mode 100644
index a9874eb2..00000000
--- a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-
-namespace Elastica\Multi;
-
-use Elastica\Client;
-use Elastica\JSON;
-use Elastica\Request;
-use Elastica\Search as BaseSearch;
-
-/**
- * Elastica multi search
- *
- * @category Xodoa
- * @package Elastica
- * @author munkie
- * @link http://www.elasticsearch.org/guide/reference/api/multi-search.html
- */
-class Search
-{
- /**
- * @var array|\Elastica\Search[]
- */
- protected $_searches = array();
-
- /**
- * @var array
- */
- protected $_options = array();
-
- /**
- * @var \Elastica\Client
- */
- protected $_client;
-
- /**
- * Constructs search object
- *
- * @param \Elastica\Client $client Client object
- */
- public function __construct(Client $client)
- {
- $this->setClient($client);
- }
-
- /**
- * @return \Elastica\Client
- */
- public function getClient()
- {
- return $this->_client;
- }
-
- /**
- * @param \Elastica\Client $client
- * @return \Elastica\Multi\Search
- */
- public function setClient(Client $client)
- {
- $this->_client = $client;
-
- return $this;
- }
-
- /**
- * @return \Elastica\Multi\Search
- */
- public function clearSearches()
- {
- $this->_searches = array();
-
- return $this;
- }
-
- /**
- * @param \Elastica\Search $search
- * @param string $key Optional key
- * @return \Elastica\Multi\Search
- */
- public function addSearch(BaseSearch $search, $key = null)
- {
- if ($key) {
- $this->_searches[$key] = $search;
- } else {
- $this->_searches[] = $search;
- }
-
- return $this;
- }
-
- /**
- * @param array|\Elastica\Search[] $searches
- * @return \Elastica\Multi\Search
- */
- public function addSearches(array $searches)
- {
- foreach ($searches as $key => $search) {
- $this->addSearch($search, $key);
- }
-
- return $this;
- }
-
- /**
- * @param array|\Elastica\Search[] $searches
- * @return \Elastica\Multi\Search
- */
- public function setSearches(array $searches)
- {
- $this->clearSearches();
- $this->addSearches($searches);
-
- return $this;
- }
-
- /**
- * @return array|\Elastica\Search[]
- */
- public function getSearches()
- {
- return $this->_searches;
- }
-
- /**
- * @param string $searchType
- * @return \Elastica\Multi\Search
- */
- public function setSearchType($searchType)
- {
- $this->_options[BaseSearch::OPTION_SEARCH_TYPE] = $searchType;
-
- return $this;
- }
-
- /**
- * @return \Elastica\Multi\ResultSet
- */
- public function search()
- {
- $data = $this->_getData();
-
- $response = $this->getClient()->request(
- '_msearch',
- Request::POST,
- $data,
- $this->_options
- );
-
- return new ResultSet($response, $this->getSearches());
- }
-
- /**
- * @return string
- */
- protected function _getData()
- {
- $data = '';
- foreach ($this->getSearches() as $search) {
- $data.= $this->_getSearchData($search);
- }
-
- return $data;
- }
-
- /**
- * @param \Elastica\Search $search
- * @return string
- */
- protected function _getSearchData(BaseSearch $search)
- {
- $header = $this->_getSearchDataHeader($search);
- $header = (empty($header)) ? new \stdClass : $header;
- $query = $search->getQuery();
-
- $data = JSON::stringify($header) . "\n";
- $data.= JSON::stringify($query->toArray()) . "\n";
-
- return $data;
- }
-
- /**
- * @param \Elastica\Search $search
- * @return array
- */
- protected function _getSearchDataHeader(BaseSearch $search)
- {
- $header = $search->getOptions();
-
- if ($search->hasIndices()) {
- $header['index'] = $search->getIndices();
- }
-
- if ($search->hasTypes()) {
- $header['types'] = $search->getTypes();
- }
-
- return $header;
- }
-}