Changeset 27815 for gs3-extensions

Show
Ignore:
Timestamp:
11.07.2013 16:15:43 (6 years ago)
Author:
kjdon
Message:

adding in facets

Location:
gs3-extensions/solr/trunk/src/perllib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm

    r27802 r27815  
    618618    $self->{'buildproc'}->set_sortfields ($self->{'collect_cfg'}->{'sortfields'}); 
    619619    } 
     620    if (defined $self->{'collect_cfg'}->{'facetfields'}) { 
     621    $self->{'buildproc'}->set_facetfields ($self->{'collect_cfg'}->{'facetfields'}); 
     622    } 
    620623    $self->{'buildproc'}->set_db_level($db_level); 
    621624    $self->{'buildproc'}->reset(); 
     
    659662}     
    660663 
    661  
     664sub build_cfg_extra { 
     665    my $self = shift (@_); 
     666    my ($build_cfg) = @_; 
     667 
     668    $self->lucenebuilder::build_cfg_extra($build_cfg); 
     669 
     670    # need to add in facet stuff 
     671    my @facetfields = (); 
     672    my @facetfieldmap = (); 
     673 
     674    foreach my $sf (@{$self->{'buildproc'}->{'facetfields'}}) { 
     675    if ($sf eq "rank") { 
     676        push(@facetfields, $sf); 
     677    } elsif ($self->{'buildproc'}->{'actualsortfields'}->{$sf}) { 
     678        my $shortname = $self->{'buildproc'}->{'sortfieldnamemap'}->{$sf}; 
     679        push(@facetfields, $shortname); 
     680        push (@facetfieldmap, "$sf\-\>$shortname"); 
     681    } 
     682     
     683    } 
     684    $build_cfg->{'indexfacetfields'} = \@facetfields; 
     685    $build_cfg->{'indexfacetfieldmap'} = \@facetfieldmap; 
     686 
    6626871; 
    663688 
  • gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm

    r27802 r27815  
    5858} 
    5959 
     60sub set_facetfields { 
     61    my $self = shift (@_); 
     62  
     63    my ($facetfields) = @_; 
     64    $self->{'facetfields'} = (); 
     65    # lets just go through and check for text, allfields, metadata which are only valid for indexes, not for facetfields 
     66    foreach my $s (@$facetfields) { 
     67    if ($s !~ /^(text|allfields|metadata)$/) { 
     68        push (@{$self->{'facetfields'}}, $s); 
     69    } 
     70    } 
     71} 
    6072 
    6173#---- 
     
    557569    if ($self->{'indexing_text'} && ($sec_tag_name ne "" || $doc_section == 1 )) { 
    558570    # add sort fields if there are any 
    559          
    560     foreach my $sfield (@{$self->{'sortfields'}}) { 
     571        my $seenfields = {}; 
     572    foreach my $sfield (@{$self->{'sortfields'}}, @{$self->{'facetfields'}}) { 
     573        print STDERR "sort/facet field = $sfield\n"; 
    561574        # ignore special field rank 
    562575        next if $sfield eq "rank"; 
     576        # ignore any we have already done - we may have duplicates in the sort and facet lists 
     577        next if (defined $seenfields->{$sfield}); 
     578        print STDERR "processing it\n"; 
     579        $seenfields->{$sfield} = 1; 
    563580        my $sf_shortname; 
    564581        if (defined $self->{'sortfieldnamemap'}->{$sfield}) {