Highlighted
Mark-sai Respected Contributor.
Respected Contributor.
406 views

Search for only container using search title clause

Hi,

How do I search for only container using title search clause in .Net SDK? Below is the sample code. But it seems to retrieve everything related to that title including records under those containers.  I just want to search if that title string exist in the container .

 

TrimMainObjectSearch objSearch = new TrimMainObjectSearch(rmDB, BaseObjectTypes.Record);
TrimSearchClause titleClause = new TrimSearchClause(rmDB, BaseObjectTypes.Record, SearchClauseIds.RecordTitle);
titleClause.SetCriteriaFromString(title);
objSearch.AddSearchClause(titleClause);

foreach (Record objRec in objSearch)
{
records.Add(objRec);
}

Tags (1)
0 Likes
2 Replies
EWillsey Acclaimed Contributor.
Acclaimed Contributor.

Re: Search for only container using search title clause

Why not do this:

 

TrimMainObjectSearch objSearch = new TrimMainObjectSearch(rmDB, BaseObjectTypes.Record);
objSearch.SearchString = $"container:[title:{title}]";

foreach (Record objRec in objSearch)
{
records.Add(objRec);
}

 
Cheers,
Erik
[EDITED: corrected based on iCognitions comment]
 
---------
Erik
CMRamble.com
0 Likes
Jan iCognition Trusted Contributor.
Trusted Contributor.

Re: Search for only container using search title clause

TrimMainObjectSearch objSearch = new TrimMainObjectSearch(rmDB, BaseObjectTypes.Record);
objSearch.SearchString = $"container:(title:{title})";

foreach (Record objRec in objSearch)
{
records.Add(objRec);
}

You'll need to use square brackets for sub-query searching (at least in CM9.1), so $"container:[title:{title}]"

Also, you might not be able to use the fancy $ interpolation if stuck using an old version of .NET

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.