Ejemplo n.º 1
0
		SELECT
			announcement.item_id AS item_id,
			announcement.item_id AS index_id,
			NULL AS version_id,
			announcement.modification_date,
			CONCAT(announcement.title, " ", announcement.description, " ", user.firstname, " ", user.lastname) AS search_data
		FROM
			announcement
		LEFT JOIN
			user
		ON
			user.item_id = announcement.creator_id
		WHERE
			announcement.deletion_date IS NULL
	';
	$indexer->add(CS_ANNOUNCEMENT_TYPE, $query);
	
	////////////////////////////
	////// Sections ////////////
	////////////////////////////
	$query = '
		SELECT
			section.item_id AS item_id,
			section.material_item_id AS index_id,
			section.version_id AS version_id,
			section.modification_date,
			CONCAT(section.title, " ", section.description, " ", user.firstname, " ", user.lastname) AS search_data
		FROM
			section
		LEFT JOIN
			user
Ejemplo n.º 2
0
<?php

require "elastic.php";
require "indexer.php";
require "searcher.php";
$indexer = new Indexer();
$indexer->setIndex("test")->setType("type");
echo "Add\n";
print_r($indexer->add(array("name" => 'asd', "phone" => "79111234567")));
print_r($indexer->add(array("name" => 'test asd', "phone" => "79133234567")));
print_r($indexer->add(array("name" => 'test', "phone" => "79155234567")));
$client = new Elastic();
echo "Get\n";
print_r($client->get(array('index' => 'test', 'type' => 'type', 'id' => 1)));
$searcher = new Searcher();
$searcher->setIndex("test")->setType("type");
echo "Search\n";
print_r($searcher->partial_query(array("name" => "te", 'phone' => '7913')));
// print_r($searcher->query_string('test +79155234*'));
echo "Clear index\n";
//print_r($indexer->clear());