Skip to content

Commit

Permalink
cwrc#4: Enable Solr in place of the RI query
Browse files Browse the repository at this point in the history
  • Loading branch information
ctgraham committed Apr 27, 2022
1 parent aa006fe commit 89f8805
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions islandora_object_field.module
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,39 @@ function islandora_object_field_autocomplete($field, $search) {
$cmodels = array_filter($field['settings']['content_models']);
$repository = islandora_get_tuque_connection()->repository;

if (module_exists('islandora_solr')) {
module_load_include('inc', 'islandora_solr', 'includes/utilities');
$qp = new IslandoraSolrQueryProcessor();
$qp->buildQuery($search);
$fq = '';
foreach ($cmodels as $cmodel) {
$fq .= ($fq ? ' OR ' : '').'"info:fedora/'.$cmodel.'"';
}
if ($fq && count($cmodel) > 1) {
$fq = '('.$fq.')';
}
if ($fq) {
$qp->solrParams['fq'][] = islandora_solr_lesser_escape(variable_get('islandora_solr_content_model_field', 'RELS_EXT_hasModel_uri_ms')).':'.$fq;
}
$label_field = variable_get('islandora_solr_object_label_field', 'fgs_label_s');
$qp->solrParams['fl'] = implode(',', array(
'PID',
$label_field,
));
$qp->solrParams['defType'] = 'dismax';
$qp->executeQuery();
$return = array();
foreach ($qp->islandoraSolrResult['response']['objects'] as $result) {
$return[$result['PID']] = t('@label (@pid)', array(
//TODO: why is $result['solr_doc'] empty? We should be able to pull $result['solr_doc'][$label_field].
'@label' => $result['object_label'],
'@pid' => $result['PID'],
));
}
drupal_json_output($return);
return;
}

// Build UNION statement.
$where_strings = array();
foreach ($cmodels as $cmodel) {
Expand Down

0 comments on commit 89f8805

Please sign in to comment.