Changeset 15764


Ignore:
Timestamp:
05/28/08 16:16:17 (13 years ago)
Author:
mdewsnip
Message:

(Adding dynamic classifiers) Updated the FRmetadataValues request code to a) remove all duplicate metadata values, b) set an occurrence count on the metadata values, and c) return the metadata values sorted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/colservr/sqlbrowsefilter.cpp

    r15757 r15764  
    111111  }
    112112
     113  // Request for the metadata values assigned to an element
    113114  if ((request.filterResultOptions & FRmetadataValues) && !request.fields.empty())
    114115  {
    115116    text_t metadata_element_name = *(request.fields.begin());
    116     logout << text_t2ascii << "Requesting metadata values for " << metadata_element_name << "...\n";
    117117    text_tarray metadata_values = sql_db_ptr->getmetadatavalues (metadata_element_name);
     118
     119    // Create a map from metadata value to ResultDocInfo_t, to remove duplicate values and obtain occurrence counts
     120    map<text_t, ResultDocInfo_t> unique_metadata_values_map;
    118121    text_tarray::iterator metadata_value_iterator = metadata_values.begin();
    119122    while (metadata_value_iterator != metadata_values.end())
    120123    {
    121       ResultDocInfo_t metadata_value_result_doc;
    122       metadata_value_result_doc.OID = *metadata_value_iterator;
    123       response.docInfo.push_back (metadata_value_result_doc);
     124      text_t metadata_value = *metadata_value_iterator;
     125
     126      // If no ResultDocInfo_t has already been created for this metadata value, create one now
     127      if (unique_metadata_values_map.find(metadata_value) == unique_metadata_values_map.end())
     128      {
     129    ResultDocInfo_t metadata_value_result_doc;
     130    metadata_value_result_doc.OID = metadata_value;
     131    metadata_value_result_doc.result_num = 1;
     132    unique_metadata_values_map[metadata_value] = metadata_value_result_doc;
     133      }
     134      // Otherwise we've seen this value before, so just update the occurrence count
     135      else
     136      {
     137    unique_metadata_values_map[metadata_value].result_num++;
     138      }
    124139
    125140      metadata_value_iterator++;
     141    }
     142
     143    // Fill in response.docInfo with the ResultDocInfo_t objects we've created above
     144    map<text_t, ResultDocInfo_t>::iterator unique_metadata_values_iterator = unique_metadata_values_map.begin();
     145    while (unique_metadata_values_iterator != unique_metadata_values_map.end())
     146    {
     147      response.docInfo.push_back ((*unique_metadata_values_iterator).second);
     148      unique_metadata_values_iterator++;
    126149    }
    127150  }
Note: See TracChangeset for help on using the changeset viewer.