[Bio] / Sprout / ERDB.pm Repository:
ViewVC logotype

Diff of /Sprout/ERDB.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.81, Wed Dec 20 20:03:25 2006 UTC revision 1.82, Tue Jan 9 01:49:57 2007 UTC
# Line 2587  Line 2587 
2587              # primary relations are allowed that privilege.              # primary relations are allowed that privilege.
2588              Trace("Checking for full-text index on $relationName.") if T(2);              Trace("Checking for full-text index on $relationName.") if T(2);
2589              if ($self->_IsPrimary($relationName)) {              if ($self->_IsPrimary($relationName)) {
2590                  # Get the relation's entity/relationship structure.                  $self->CreateSearchIndex($relationName);
                 my $structure = $self->_GetStructure($relationName);  
                 Trace("Checking for search fields in $relationName.") if T(3);  
                 # Check for a searchable fields list.  
                 if (exists $structure->{searchFields}) {  
                     # Here we know that we need to create a full-text search index.  
                     # Get an SQL-formatted field name list.  
                     my $fields = join(", ", _FixNames(@{$structure->{searchFields}}));  
                     # Create the index.  
                     $dbh->create_index(tbl => $relationName, idx => "search_idx",  
                                        flds => $fields, kind => 'fulltext');  
                     Trace("Index created for $fields in $relationName.") if T(2);  
                 }  
2591              }              }
2592          }          }
2593      }      }
# Line 2611  Line 2599 
2599      return $retVal;      return $retVal;
2600  }  }
2601    
2602    =head3 CreateSearchIndex
2603    
2604    C<< $erdb->CreateSearchIndex($objectName); >>
2605    
2606    Check for a full-text search index on the specified entity or relationship object, and
2607    if one is required, rebuild it.
2608    
2609    =over 4
2610    
2611    =item objectName
2612    
2613    Name of the entity or relationship to be indexed.
2614    
2615    =back
2616    
2617    =cut
2618    
2619    sub CreateSearchIndex {
2620        # Get the parameters.
2621        my ($self, $objectName) = @_;
2622        # Get the relation's entity/relationship structure.
2623        my $structure = $self->_GetStructure($objectName);
2624        # Get the database handle.
2625        my $dbh = $self->{_dbh};
2626        Trace("Checking for search fields in $objectName.") if T(3);
2627        # Check for a searchable fields list.
2628        if (exists $structure->{searchFields}) {
2629            # Here we know that we need to create a full-text search index.
2630            # Get an SQL-formatted field name list.
2631            my $fields = join(", ", _FixNames(@{$structure->{searchFields}}));
2632            # Create the index. If it already exists, it will be dropped.
2633            $dbh->create_index(tbl => $objectName, idx => "search_idx",
2634                               flds => $fields, kind => 'fulltext');
2635            Trace("Index created for $fields in $objectName.") if T(2);
2636        }
2637    }
2638    
2639  =head3 DropRelation  =head3 DropRelation
2640    
2641  C<< $erdb->DropRelation($relationName); >>  C<< $erdb->DropRelation($relationName); >>

Legend:
Removed from v.1.81  
changed lines
  Added in v.1.82

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3