cancel
Showing results for 
Search instead for 
Did you mean: 

search with three search creteria using MDM java apis

NarendraChandel
Contributor
0 Kudos

Hi Experts,

Using MDM JAVA APIS

I need some small info.I want to fetch records from MDM repository using some search criteria. Am able to fetch the records using one search criteria but how do we have to do for multiple search criteria.

snippet/example would help.

i want to search with three search creteria.

thanks

Narendra

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

For clubbing search criteria you have to use SearchGroup class. A SearchGroup instance can combine multiple search item using Logical Operators like AND / OR.

A sample code can be like this,

SearchDimension searchDimension1 = new FieldSearchDimension(FieldId1);

SearchConstraint searchConstraint1 = new DateTimeSearchConstraint(MdmValue, DateTimeSearchConstraint.LESS_THAN);

SearchGroup searchGroup = new SearchGroup();

searchGroup.addSearchItem(searchDimension1 ,searchConstraint1 );

searchGroup.addSearchItem(searchDimension2 ,searchConstraint2);

searchGroup.addSearchItem(searchDimension3 ,searchConstraint3);

serachGroup.setComparisonOperator(SearchGroup.AND_OPERATOR / SearchGroup.OR_OPERATOR);

Search search = new Search();

search.addSearchItem(searchGroup);

Pass search object to RetrieveLimitedRecordsCommand.

Regards,

Suresh

Greg_Austin
Active Participant
0 Kudos

A SearchGroup works fine if the same field is being searched, for example field A = value c OR field A = value b. If your search constraints are for different fields just keep adding them to the Search object with the addSearchItem method, for example A = b && D = e.

From the API javadocs.

1. At most one level of nesting is allowed.

For examples:

A=a && B=b && C=c // no nesting, OK

(A=a || A=b) &&(C=c) // one level nesting, OK

((A=a || A=b) && (C=c)) && (D=d) // two or more level nesting, not OK

2. All field dimensions within a search group needs to be the same field dimension.

For examples:

(A=a || A=b) // OK

(A=a || B=b) // not OK

Answers (1)

Answers (1)

NarendraChandel
Contributor
0 Kudos

thanks a lot

Regards

Narendra