2012-03-15 16:29:17 +00:00
|
|
|
<?php
|
|
|
|
|
require_once('vendor/SolrPhpClient/Apache/Solr/Service.php');
|
|
|
|
|
require_once('functions_sistema.php');
|
|
|
|
|
|
|
|
|
|
function solr_anadir_cv($oid, $filename) {
|
|
|
|
|
|
|
|
|
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
|
|
|
|
$ext = ".".$ext;
|
|
|
|
|
$nombre = basename($filename, $ext);
|
|
|
|
|
|
|
|
|
|
$solr = new Apache_Solr_Service('localhost', 8983, '/solr/');
|
|
|
|
|
if ($solr->ping())
|
|
|
|
|
{
|
|
|
|
|
$document = new Apache_Solr_Document();
|
|
|
|
|
$document->id = $nombre;
|
|
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
|
'resource.name' => basename($filename),
|
|
|
|
|
'literal.id' => $nombre,
|
|
|
|
|
'literal.candidato' => $oid,
|
|
|
|
|
'uprefix' => 'attr_',
|
|
|
|
|
'fmap.content' => 'attr_content',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$solr->extract($filename, $params, $document);
|
|
|
|
|
$solr->commit();
|
|
|
|
|
$solr->optimize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function solr_eliminar_cv($filename) {
|
|
|
|
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
|
|
|
|
$ext = ".".$ext;
|
|
|
|
|
$nombre = basename($filename, $ext);
|
|
|
|
|
|
|
|
|
|
$solr = new Apache_Solr_Service('localhost', 8983, '/solr/');
|
|
|
|
|
if ($solr->ping())
|
|
|
|
|
{
|
|
|
|
|
$solr->deleteById($nombre);
|
|
|
|
|
$solr->commit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function solr_eliminar_todo() {
|
|
|
|
|
$solr = new Apache_Solr_Service('localhost', 8983, '/solr/');
|
|
|
|
|
if ($solr->ping())
|
|
|
|
|
{
|
|
|
|
|
$solr->deleteByQuery('id:*');
|
|
|
|
|
$solr->commit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function solr_buscar_palabra($palabra) {
|
|
|
|
|
$ids = array();
|
|
|
|
|
$query = $palabra;
|
|
|
|
|
if (get_magic_quotes_gpc() == 1)
|
|
|
|
|
{
|
|
|
|
|
$query = stripslashes($query);
|
|
|
|
|
}
|
|
|
|
|
$query = 'attr_content:'.$query;
|
|
|
|
|
|
|
|
|
|
$solr = new Apache_Solr_Service('localhost', 8983, '/solr/');
|
|
|
|
|
if ($solr->ping())
|
|
|
|
|
{
|
|
|
|
|
//try {
|
2012-03-15 18:23:33 +00:00
|
|
|
$results = $solr->search($query, 0, 100);
|
2012-03-15 16:29:17 +00:00
|
|
|
if ($results) {
|
|
|
|
|
foreach ($results->response->docs as $doc) {
|
|
|
|
|
$ids[] = $doc->attr_candidato;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*}
|
|
|
|
|
catch (Exception $e) {
|
|
|
|
|
dbug($e->__toString());
|
|
|
|
|
echo dbug('print');
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
return $ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|