Skip to Content
avatar image
Former Member

Combined attribute search with NullSearchConstraint on MDM 5.5 and Java API

Hi everyone,

I have a main table "Products" with a taxonomy table "Main_WI_Classification".

Example of my tables:

No Main_Material_Number (main) Main_Article_Name (main) attribute1 (taxonomy) attribute2 (taxonomy)

1 1812190000 'SL-SMT 5.00/19/90G 3.2' Yes YNY

2 1812000000 'SL-SMT 5.00/19/90G 3.2'

3 1812200000 'SL-SMT 5.00/19/90G 3.2' Yes

I use a search with 3 search parameters, the first parameter is for a field in the main table ("Main_Article_Name") and the second and third parameter is for two attributes ("attribute1" and "attribute2") in the taxonomy table.

As ComparisonOperator I use the AND-operator.

I want to get the third article as result.

Search Parameter:

1. Main_Article_Name = "SL-SMT 5.00/19/90G 3.2"

2. attribute1 = "Yes"

3. attribute2 = NULL

When I perform the search with all 3 search parameters set, it delivers no results.

When I perform the search with the first and second search parameters set, it delivers 1 and 3.

When I perform the search with the first and third search parameters set, it delivers 2 and 3.

How can I combine the search parameters to work on both attributes to deliver me the third article?

Or is there another way to search for Null Values in attributes of taxonomy tables?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Aug 24, 2009 at 12:21 PM

    here my coding:

    TableId mainTableId = rSchema.getTableId("Products");
    
    // get taxonomy table id
    FieldId taxFieldId = rSchema.getFieldId("Products", "Main_WI_Classification");
    
    // fields for the result defenition
    FieldId[] fieldIds = new FieldId[2];
    fieldIds[0] = rSchema.getFieldId("Products", "Main_Material_Number");
    fieldIds[1] = rSchema.getFieldId("Products", "Main_Article_Name");
    
    ResultDefinition rd = new ResultDefinition(mainTableId);
    rd.setSelectFields(fieldIds);
    
    // new search object
    Search attrSearch = new Search(mainTableId);
    attrSearch.setComparisonOperator(Search.AND_OPERATOR);
    
    // Search parameter 1
    SearchParameter spMatName = new SearchParameter(
    	new FieldSearchDimension(fieldIds[1]),
    	new TextSearchConstraint("SL-SMT 5.00/19/90G 3.2", TextSearchConstraint.EQUALS));
    
    // Search parameter 2
    SearchParameter spAttr1 = new SearchParameter(
    	new AttributeSearchDimension(taxFieldId, attrId1),
    	new TextSearchConstraint("Yes", TextSearchConstraint.EQUALS));
    
    // Search parameter 3
    SearchParameter spAttr2 = new SearchParameter(
    	new AttributeSearchDimension(taxFieldId, attrId2), new NullSearchConstraint(false));
    
    attrSearch.addSearchItem(spMatName);
    attrSearch.addSearchItem(spAttr1);
    attrSearch.addSearchItem(spAttr2);
    
    try
    {
    	RetrieveLimitedRecordsCommand retLimRecComm = new RetrieveLimitedRecordsCommand(usc);
    	retLimRecComm.setResultDefinition(rd);
    	retLimRecComm.setSearch(attrSearch);
    
    	retLimRecComm.execute();
    	RecordResultSet rs = retLimRecComm.getRecords();
    	System.out.println("Found: " + rs.getCount());
    	for (int i = 0; i < rs.getCount(); i++)
    	{
    		System.out.println(
    			rs.getRecord(i).getFieldValue(fieldIds[0]).toString()
    				+ "\t"
    				+ rs.getRecord(i).getFieldValue(fieldIds[1]).toString());
    	}
    }
    .
    .
    .
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 31, 2009 at 07:53 AM

    no ideas?

    Add comment
    10|10000 characters needed characters exceeded