public function execute($response) { $this->getCache()->resetCache(); $result = null; $jsonObj = json_decode($response); $scrollId = $jsonObj->_scroll_id; $total = $jsonObj->hits->total; foreach ($jsonObj->hits->hits as $index => $tmpObj) { $this->getCache()->add($tmpObj); } if ($this->getCache()->getCount() != $total) { $cmdb = new CMDB(null); $queryObj = new QueryObj(); $queryObj->setQueryUrl(self::SCROLL_URL); $queryObj->setQueryString('{"scroll_id":"' . $scrollId . '"}'); $queryObj->setExecutorName(self::EXECUTOR_NAME); $cmdb->addObserver($queryObj); do { $results = $cmdb->fetch($queryObj); $tmpjsonObj = json_decode($results); foreach ($tmpjsonObj->hits->hits as $index => $tmpObj) { $this->getCache()->add($tmpObj); } unset($tmpjsonObj); } while ($this->getCache()->getCount() != $total); } if (!!($executor = GlobalArgParser::getExecutor())) { $executorObj = new $executor(); $result = $executorObj->execute($this->getCache()->get()); } return $result; }
public function __construct($queryObj) { parent::__construct($queryObj); $queryObj->setExecutorName(GlobalArgParser::getExecutor()); $queryObj->setQueryString('{"from":0,"size":0,"fields":["_id","state","config.fqdn"],"query":{"query_string":{"query":"state:active"}},"facets":{"facet":{"terms":{"size":100,"field":"domain"}}}}'); }