cancel
Showing results for 
Search instead for 
Did you mean: 

how to search with multiple search condition in MDM5.5 API.

Former Member
0 Kudos

hello my friends,

how can i obtain right records like SQL: "select * from mainTable where (A=a and B=b) or (A=c and B=d) or (A=e and B=f)";

A,B:fieldCode

a,b,c,d,e,f :fieldValue

Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Orloffmax,

You can use SearchGroup class in this case. You have to create 3 SearchGroup objects here

1. SearchGoup for (A=a and B=b) with SearchGroup.setComparisonOperator(SearchGroup.AND_OPERATOR)

2. SearchGoup for (A=c and B=d) with SearchGroup.setComparisonOperator(SearchGroup.AND_OPERATOR)

3. SearchGoup for (A=e and B=f) with SearchGroup.setComparisonOperator(SearchGroup.AND_OPERATOR)

4. Create a Search object and use the above SearchGroup objects as Search.addSearchItem(SearchGroup). Add all the 3 above SearchGroup as SearchItem in Search object

5. In the Search object set the comparison operator as OR_OPERATOR.

Hope this helps you.

Regards,

Sruti

Former Member
0 Kudos

thanks sruti,

but the error message is:

java.lang.IllegalArgumentException: Search dimensions within a search group need to be the same.

that means SearchDimension A and SearchDimension B can not be in the same SearchGroup.

hope your reply , thanks.

Former Member
0 Kudos

Hi Orloffmax,

I missed a point here.

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

For example:

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

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

So you are getting the below error.

So the only option left to perform search now is

1. Create a Search Object for (A=a and B=b), Perform the search and Save the list of RecordsIds

2. Create a Search Object for (A=c and B=d), Perform the search and Save the list of RecordsIds

3. Create a Search Object for (A=e and B=f), Perform the search and Save the list of RecordsIds

4. As you have to perform an OR Operation Search on all the above 3, you can do a round about thing as APIs are not helping much. You can put all the above Records in a HashMap with both Key and Value as RecordId. By doing this you'll get a list of Unique record Ids.

I am not able to find out a way in which the APIs can help you more, so have suggested you such an approach. If you ever find a better one, do share please.

Regards,

Sruti

Former Member
0 Kudos

thanks sruti,

1. perform many times to search MDM repository

2. perform one time to search MDM repository

I have ever been used the first method,but the rapidity is too slow, for my thousands of data scalar.

I hope to find an approach to execute one time to search all records.

Because the "1" method has to perform many times' search , the speed executes a long time.

hope all friends reply,

thanks a lot.