Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2014-05-23 15:48:49

catinahat
Member
Registered: 2014-05-23
Posts: 3

Search.AdvancedSearch

Using Search.AdvancedSearch, how can I specify that all query terms in the array have to be met (ALL instead of ANY)?

I have tried exactMatches:"true", but that doesn't seem to do much.

Thanks!

Last edited by catinahat (2014-05-23 21:13:00)

Offline

#2 2014-05-28 12:01:27

steve
Third Light Staff
Registered: 2013-06-06
Posts: 92

Re: Search.AdvancedSearch

Hi Catinahat,

At the moment it is not possible to specify an ALL or ANY condition through the API in the way that it can be achieved through the IMS web interface, sorry.

The exactMatches term you used only applies to Search.GeneralSearch() and isn't available for Search.AdvancedSearch().

One thing to note however is that Search.AdvancedSearch() does default to ALL so multiple calls to Search.AdvancedSearch() with different terms each time would allow you to build an array or results equivalent to ANY.

Your message above implies that you are seeing ANY behaviour but we can confirm that the method only operates as ALL.

Best Regards,
Steve

Offline

#3 2014-05-28 15:06:49

steve
Third Light Staff
Registered: 2013-06-06
Posts: 92

Re: Search.AdvancedSearch

Reference Example

This script makes use of the PHP client

<?php

// Search_AdvancedSearch

ob_start(); //buffer output

// Customise these values to match your system

// URL of the IMS site
$strIMSSite = "http://yoursite.com";

// API key generated from Configuration -> Site Options -> IMS API
$strAPIKey = "IJPtL39u8vMfntBgVm7bvGDGUXRRu8FC";

// Display request and response data
// Choices are "json", "array" or ""
$arrExtraParams = array("DEBUG"=> "DisplayRequestAndResponseJSON");
$arrExtraParams = array("DEBUG"=> "DisplayRequestAndResponseArray");

chdir(__DIR__);

require_once("../imsapiclient.php");
require_once("displaysupport.php");

$searchTerm = "Cat with toy";
$fieldId = 111; // Caption
$conditionId = 3; // IS

$searchTermTwo = "beavis";
$fieldIdTwo = 106; // Keywords
$conditionIdTwo = 0; // Contains

// End of custom section

try
{
	BeginHTMLPage();
	$objAPI = new IMSApiClient($strIMSSite, $strAPIKey, $arrExtraParams);

	DisplayOutputString("<hr>");
	DisplayOutputString("<b>Caption IS '$searchTerm'");
	DisplayOutputString("AND"); 
	DisplayOutputString("<b>Keywords CONTAIN '$searchTermTwo'"); 
	$arrInParams = 
					array(
						"query" => array(
										array("fieldId" => $fieldId, "conditionId"=> $conditionId, "value"=> $searchTerm),
										array("fieldId" => $fieldIdTwo, "conditionId"=> $conditionIdTwo, "value"=> $searchTermTwo)
									)
						);
								
	$arrOutParams = $objAPI->Search_AdvancedSearch($arrInParams);

	DisplayOutputString("<hr>");
	DisplayOutputString("<b>Codes for fieldId and conditionIds</b>"); 
	$arrInParams = array();
	$arrOutParams = $objAPI->Search_GetSearchConfiguration($arrInParams);


	EndHTMLPage();
}
catch(IMSApiClientException $e)
{
    header("HTTP/1.1 500 Internal Server Error");
    echo "<!DOCTYPE html>\n<html><head><title>Error</title></head><body><h1>Error: ".get_class($e)."</h1><p>".$e->getMessage()."</p></body></html>";
    echo"<pre>";
    print_r($e);
    echo"</pre>";
}

?>

Offline

#4 2014-05-29 16:18:02

catinahat
Member
Registered: 2014-05-23
Posts: 3

Re: Search.AdvancedSearch

Thanks for the help so far! Is it possible to constrain the search to specific containerId?

Offline

#5 2014-06-03 08:49:12

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 96

Re: Search.AdvancedSearch

Hi Catinahat,

Yes, provided it is a folder: field ID 11 (as returned from Search.GetSearchConfiguration) allows you to specify a folder or subtree.

It is not possible to restrict the search to a particular collection or smartfolder - although as a workaround you could create a user with restricted access and perform the search as them.

Dominic

Offline

Board footer