cancel
Showing results for 
Search instead for 
Did you mean: 

How to do this type of Search using MDM Java API ?

Former Member
0 Kudos

Hello MDM Gurus:

Here is my MDM Java Search problem.

I am searching in the main table "Products", for the fields

-Product Name

-Category (a taxonomy lookup field).

Since Category is a taxonomy lookup field, I am using

SupportingResultDefinition, for it.

Then I have Child_ID(field) value of Category(table).

It is a numerical value.

To formulate the search item, to be given to the Search

Object, I used PicklistSearchConstraint, and Keyword

SearchDimension, like...

FieldId ctgChildIdFID =  bseConnDtls.getFieldId("Categories", "Child_ID");
MdmValue[] lkpValueArray = getMatchingCategoryFieldIds(wdThis,srchString,"Categories","Child_ID",bseConnDtls);
// To limit the results from a search by a lookup field you can use a PickListSeachConstraint 
PickListSearchConstraint plsc = new PickListSearchConstraint(lkpValueArray);
// Don't use the below command, because it should not be used for 
// taxonomy and qualified table fields
//FieldSearchDimension fsd = new FieldSearchDimension(ctgChildIdFID); 
KeywordSearchDimension kwsd = new KeywordSearchDimension();
search.addSearchItem(kwsd, plsc);

Now I continue with the rest of the coding, and I am getting the

following error "Unexpected Search Dimension type 3"

Anybody has any ideas ??

Your help is highly appreciated,

Prasad Nutalapati

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You have to use FieldSearchDimension in the search query.

Sample Code:

// Create a FieldSearchDimension for the Lookup field

FieldSearchDimension fsdLookuptableType = new FieldSearchDimension(LookupDisplay);

// Create a NumericSearchConstraint for the entered value.

NumericSearchConstraint tscTypeRoot = new NumericSearchConstraint(serFieldValue, NumericSearchConstraint.EQUALS);

// Result Set for the lookup table.

ResultDefinition rdSerLookup = new ResultDefinition(lookupFieldSer.getLookupTableId());

rdSerLookup.addSelectField(LookupDisplay);

// Searching the record by specifying the Table Name, Field Name and Condition

Search seSearchTypeRoot = new Search(lookupFieldSer.getLookupTableId());

// Add the parameters to the search

seSearchTypeRoot.addSearchItem(fsdLookuptableType, tscTypeRoot);

// Retrieve the Records

Record[] resSetLookup = retRec.retrieveLimitedRecord(connections,sessionId, seSearchTypeRoot, rdSerLookup);

List<MdmValue> valueSearch = new ArrayList<MdmValue>();

for (int r = 0; r < resSetLookup.length; r++)

{

// Array of MdmValue for adding in the search parameter.

lkValue = new LookupValue(resSetLookup[r].getId());

valueSearch.add(lkValue);

}

MdmValue[] lookupSerValues = (MdmValue[]) valueSearch.toArray(new MdmValue[valueSearch.size()]);

// Create a PickListSearchConstraint for the entered value.

PickListSearchConstraint tscMainTypeRoot = new PickListSearchConstraint(lookupSerValues);

// Create a FieldSearchDimension for the entered field

FieldSearchDimension fsdMaintableType = new FieldSearchDimension(serFieldName.getId());

// Searching the record by specifying the Table Name, Field Name andCondition

Search seSearchMainRoot = new Search(serTableName.getId());

seSearchMainRoot.addSearchItem(fsdMaintableType, tscMainTypeRoot);

Thanks.