Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,44 +11,51 @@
|
||||
namespace IPS\Content\Search\Elastic;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content;
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Content\Item;
|
||||
use IPS\Http\Url;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Elasticsearch Mass Indexer
|
||||
*/
|
||||
class _MassIndexer extends \IPS\Content\Search\Elastic\Index
|
||||
class MassIndexer extends Index
|
||||
{
|
||||
/**
|
||||
* @brief Data to store in bulk
|
||||
*/
|
||||
protected $data = array();
|
||||
protected ?array $data = array();
|
||||
|
||||
/**
|
||||
* Index an item
|
||||
*
|
||||
* @param \IPS\Content\Searchable $object Item to add
|
||||
* @param Content $object Item to add
|
||||
* @return void
|
||||
*/
|
||||
public function index( \IPS\Content\Searchable $object )
|
||||
public function index( Content $object ): void
|
||||
{
|
||||
if ( $indexData = $this->indexData( $object ) and $indexData['index_permissions'] )
|
||||
{
|
||||
if ( $object instanceof \IPS\Content\Item )
|
||||
if ( $object instanceof Item )
|
||||
{
|
||||
$parent = $object;
|
||||
}
|
||||
elseif ( $object instanceof \IPS\Content\Comment )
|
||||
elseif ( $object instanceof Comment )
|
||||
{
|
||||
$parent = $object->item();
|
||||
}
|
||||
|
||||
$this->data[] = array(
|
||||
'index' => array(
|
||||
'_index' => trim( $this->url->data[ \IPS\Http\Url::COMPONENT_PATH ], '/' ),
|
||||
'_index' => trim( $this->url->data[ Url::COMPONENT_PATH ], '/' ),
|
||||
'_type' => '_doc',
|
||||
'_id' => $this->getIndexId( $object ),
|
||||
)
|
||||
@@ -73,7 +80,7 @@ class _MassIndexer extends \IPS\Content\Search\Elastic\Index
|
||||
}
|
||||
$json = implode( "\n", $json );
|
||||
|
||||
\IPS\Content\Search\Elastic\Index::request( $this->url->setPath( '/_bulk' ) )->setHeaders( array( 'Content-Type' => 'application/x-ndjson' ) )->post( $json . "\n" );
|
||||
Index::request( $this->url->setPath( '/_bulk' ) )->setHeaders( array( 'Content-Type' => 'application/x-ndjson' ) )->post( $json . "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user