Example #1
0
<?php

require dirname(__FILE__) . '/PhpBuf/lib/PhpBuf.php';
require dirname(__FILE__) . '/proto/FullTextService.php';
require dirname(__FILE__) . '/proto/QueryService.php';
$ctx = new PhpBuf_RPC_Context();
$ctx->addServer('localhost', 17001);
$service = new Temperance_FullTextService($ctx);
$setParam = new Temperance_FullText_Request_Add();
$setParam->key = 'hoge';
$setParam->str = '本日は晴天なり';
$setParam->value = 'value-1';
$setParam->parser = Temperance_FullText_Request_Parser::BIGRAM;
$service->add($setParam);
$setParam = new Temperance_FullText_Request_Add();
$setParam->key = 'hoge';
$setParam->str = '本日は雨天なり';
$setParam->value = 'value-2';
$setParam->parser = Temperance_FullText_Request_Parser::BIGRAM;
$service->add($setParam);
$service = new Temperance_QueryService($ctx);
$getParam = new Temperance_Query_Request_Select();
$getParam->query = 'FROM hoge IN GRAM("寒天などを食べた")';
$result = $service->select($getParam);
var_dump($result->values);
$getParam = new Temperance_Query_Request_Select();
$getParam->query = 'FROM hoge IN GRAM("運動会は雨天決行です")';
$result = $service->select($getParam);
var_dump($result->values);
Example #2
0
<?php

require dirname(__FILE__) . '/lib/MessagePackRPC/Client.php';
require dirname(__FILE__) . '/msgpack/FullTextService.php';
require dirname(__FILE__) . '/msgpack/QueryService.php';
$service = new Temperance_FullTextService('localhost', 17001);
$service->add('hoge', '本日は晴天なり', 'value-1', Temperance_FulltextService::PARSER_MECAB);
$service->add('hoge', '本日は雨天なり', 'value-2', Temperance_FulltextService::PARSER_MECAB);
$service = new Temperance_QueryService('localhost', 17001);
$result = $service->select('FROM hoge IN MECAB("本日")');
var_dump($result);
$result = $service->select('FROM hoge NOT MECAB("昨日")');
var_dump($result);
Example #3
0
<?php

require dirname(__FILE__) . '/lib/MessagePackRPC/Client.php';
require dirname(__FILE__) . '/msgpack/FullTextService.php';
require dirname(__FILE__) . '/msgpack/QueryService.php';
$service = new Temperance_FullTextService('localhost', 17001);
$service->add('hoge', '本日は晴天なり', 'value-1', Temperance_FulltextService::PARSER_BIGRAM);
$service->add('hoge', '本日は雨天なり', 'value-2', Temperance_FulltextService::PARSER_BIGRAM);
$service = new Temperance_QueryService('localhost', 17001);
$result = $service->select('FROM hoge IN GRAM("寒天などを食べた")');
var_dump($result);
$result = $service->select('FROM hoge IN GRAM("運動会は雨天決行です")');
var_dump($result);
Example #4
0
<?php

require dirname(__FILE__) . '/lib/MessagePackRPC/Client.php';
require dirname(__FILE__) . '/msgpack/FullTextService.php';
require dirname(__FILE__) . '/msgpack/QueryService.php';
$service = new Temperance_FullTextService('localhost', 17001);
$service->add('hoge', '本日は晴天なり', 'value-1', Temperance_FulltextService::PARSER_PREFIX);
$service->add('hoge', '本日は雨天なり', 'value-2', Temperance_FulltextService::PARSER_PREFIX);
$service = new Temperance_QueryService('localhost', 17001);
$result = $service->select('FROM hoge IN PREFIX("本日は")');
var_dump($result);
$result = $service->select('FROM hoge IN PREFIX("本日は晴天")');
var_dump($result);
Example #5
0
<?php

require dirname(__FILE__) . '/lib/MessagePackRPC/Client.php';
require dirname(__FILE__) . '/msgpack/ListService.php';
require dirname(__FILE__) . '/msgpack/QueryService.php';
$service = new Temperance_ListService('localhost', 17001);
echo 'add key: hoge', PHP_EOL;
$service->add('hoge', 'value-1');
$service->add('hoge', 'value-2');
echo 'add key: foo', PHP_EOL;
$service->add('foo', 'value-1');
$service->add('foo', 'value-3');
$service = new Temperance_QueryService('localhost', 17001);
$result = $service->select('FROM hoge IN DATA(foo)');
var_dump($result);
$result = $service->select('FROM hoge NOT DATA(foo)');
var_dump($result);