Changeset 27802 for gs3-extensions

Show
Ignore:
Timestamp:
11.07.2013 11:42:19 (6 years ago)
Author:
kjdon
Message:

adding in code for sort fields. just copied form lucene build code

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

Legend:

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

    r27781 r27802  
    291291            $schema_insert_xml .=   "type=\"location\" "; 
    292292        } 
    293         elsif ($field ne "ZZ" && $field ne "TX") 
    294         { 
    295             $schema_insert_xml .=   "type=\"string\" "; 
    296         } 
     293#       elsif ($field ne "ZZ" && $field ne "TX") 
     294#       { 
     295#           $schema_insert_xml .=   "type=\"string\" "; 
     296#       } 
    297297        else 
    298298        { 
     
    615615    #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'}); 
    616616    $self->{'buildproc'}->set_levels ($local_levels); 
     617    if (defined $self->{'collect_cfg'}->{'sortfields'}) { 
     618    $self->{'buildproc'}->set_sortfields ($self->{'collect_cfg'}->{'sortfields'}); 
     619    } 
    617620    $self->{'buildproc'}->set_db_level($db_level); 
    618621    $self->{'buildproc'}->reset(); 
  • gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm

    r25846 r27802  
    554554    } 
    555555         
     556    # only add sort fields for this section if we are indexing this section, we are doing section level indexing or this is the top section 
     557    if ($self->{'indexing_text'} && ($sec_tag_name ne "" || $doc_section == 1 )) { 
     558    # add sort fields if there are any 
     559         
     560    foreach my $sfield (@{$self->{'sortfields'}}) { 
     561        # ignore special field rank 
     562        next if $sfield eq "rank"; 
     563        my $sf_shortname; 
     564        if (defined $self->{'sortfieldnamemap'}->{$sfield}) { 
     565        $sf_shortname = $self->{'sortfieldnamemap'}->{$sfield}; 
     566        } 
     567        else { 
     568        $sf_shortname = $self->create_sortfield_shortname($sfield); 
     569        $self->{'sortfieldnamemap'}->{$sfield} = $sf_shortname; 
     570        $self->{'sortfieldnamemap'}->{$sf_shortname} = 1; 
     571        } 
     572        my @metadata_list = (); # put any metadata values in here 
     573        foreach my $submeta (split /,/, $sfield) { 
     574        $submeta =~ s/^ex\.([^.]+)$/$1/; #strip off ex. iff it's the only metadata set prefix (will leave ex.dc.* intact) 
     575         
     576        my @section_metadata = @{$doc_obj->get_metadata ($section, $submeta)}; 
     577            if ($section ne $doc_obj->get_top_section() && defined ($self->{'sections_sort_on_document_metadata'})) { 
     578            if ($self->{'sections_sort_on_document_metadata'} eq "always" || ( scalar(@section_metadata) == 0 && $self->{'sections_sort_on_document_metadata'} eq "unless_section_metadata_exists")) { 
     579                push (@section_metadata, @{$doc_obj->get_metadata ($doc_obj->get_top_section(), $submeta)}); 
     580            } 
     581            } 
     582        push (@metadata_list, @section_metadata); 
     583        } 
     584        my $new_text = ""; 
     585        foreach my $item (@metadata_list) { 
     586        &ghtml::htmlsafe($item); 
     587        $new_text .= "$item"; 
     588        } 
     589        if ($new_text =~ /\S/) { 
     590        #$new_text = "<$sf_shortname index=\"1\" tokenize=\"0\">$new_text</$sf_shortname>"; 
     591        $new_text = "<field name=\"$sf_shortname\">$new_text</field>\n"; 
     592        # filter the text??? 
     593        $text .= "$new_text"; # add it to the main text block 
     594        print STDERR "adding in sort text $new_text\n"; 
     595        $self->{'actualsortfields'}->{$sfield} = 1; 
     596        } 
     597    } 
     598    } 
     599 
    556600    # add in end tag if at top-level doc root, or indexing at the section level 
    557601    $text .= $end_sec if ($sec_tag_name ne ""); 
     
    565609 
    566610##    $text .= "<commit/>\n"; 
     611    open (TEXTOUT, ">text.out"); 
     612    print TEXTOUT "$text"; 
     613    close TEXTOUT; 
    567614 
    568615    print $solrhandle $text;