Subversion Repositories xrowsearch

[/] [trunk/] [cronjobs/] [xrowsearch.php] - Blame information for rev 1

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1 rrobert
<?php
2
 
3
 
4
global $cli, $isQuiet;
5
 
6
$plugins = xrowExternalSearchProvider::getExternalProviders();
7
 
8
$cli = $GLOBALS['cli'];
9
 
10
foreach ( $plugins as $plug )
11
{
12
 
13
 
14
    if ( ! $plug instanceof ExternalSearchXMLPlugin )
15
    {
16
        throw new Exception( "Provider Plugin not found." );
17
    }
18
 
19
    $records = $plug->load();
20
 
21
 
22
 
23
    // setup
24
    $handler = new xrowSOLRHandler();
25
    $manager = new ezcSearchEmbeddedManager();
26
    $session = new ezcSearchSession( $handler, $manager );
27
 
28
    $plug->delete($handler);
29
 
30
    $session->beginTransaction();
31
 
32
    if ( ! $isQuiet )
33
    {
34
        $amount = count( $records );
35
        $cli->output( "Adding $amount items to the index." );
36
        $output = new ezcConsoleOutput();
37
        $bar = new ezcConsoleProgressbar( $output, $amount );
38
    }
39
    foreach ( $records as $key => $elem )
40
    {
41
        if ( ( $key % 499 ) === 0 and $key !== 0 )
42
        {
43
 
44
            $session->commit();
45
 
46
            sleep( 3 );
47
 
48
            $session->beginTransaction();
49
 
50
        }
51
        $session->index( $elem );
52
        if ( isset( $bar ) )
53
        {
54
            $bar->advance();
55
        }
56
    }
57
    if ( ! $isQuiet )
58
    {
59
        $bar->finish();
60
        $cli->output( "\n" );
61
    }
62
 
63
    $session->commit();
64
 
65
    sleep( 3 );
66
 
67
}