Skip to content

Commit

Permalink
fix for query format.
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabzee committed Nov 4, 2024
1 parent 8f17865 commit c53f84c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions RedcapOneDirectoryLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ public function redcap_survey_page_top($project_id, $record, $instrument, $event
public function searchUsers($term)
{
// Build search object
$search = new \stdClass();
$search->query->multi_match->query = $term;
$search->query->multi_match->fields = [ "_all" ];
$headers = [
'Content-Type' => 'application/json'
];
$body = '{
"query": {
"multi_match": {
"query": "'.$term.'",
"operator": "and",
"type": "best_fields"
}
}
}';

// Tried other searches but wouldn't return sunet lookup or email lookups. I think
// those fields don't have indexing configured so it can't do much
Expand All @@ -65,8 +74,9 @@ public function searchUsers($term)
// $search->query->multi_match->fields = [ "first_name", "last_name", "fullname", "email", "affiliate", "title", "suid" ];

// Do a search
$q = $this->getClient()->request('GET', $this->getServerURL(), [
'body' => json_encode($search)
$q = $this->getClient()->post($this->getServerURL(), [
'body' => $body,
'headers' => $headers,
]);

$result = $q->getBody()->getContents();
Expand Down

0 comments on commit c53f84c

Please sign in to comment.