cancel
Showing results for 
Search instead for 
Did you mean: 

Keyword Search using the SOUNDS_LIKE modifier, Java API

Former Member
0 Kudos

Hello guys:

Does anyone have a piece of code that shows how can I do a search, using the keyword and the SOUNDS_LIKE mod, like on the Data Manager?

I've seen the blog "Performing Free Form Searches with MDM Java API" but I'm afraid this doesn't apply (it's about free-form, as the name says)

Thanks!

Alejandro

View Entire Topic
Former Member
0 Kudos

Hi Alejandro,

maybe this piece of code helps you a bit. The most important is the static attribute SOUNDS_LIKE of the TextSearchConstraint class.

Also try to find the MDM Java Example files @ service.sap.com/installMDM . There is a complete introduction on how to search against an MDM repository which is very useful.


		// assumption: 
		// you have connected to some repository which contains a field "Material Number" 
		// with a session and you have already read the MainTable properties to identify
		// the MainTableID, as well as some fields yo want to read.		

		// set search conditions
		Search search = new Search(<yourMainTableId>);
		String fieldname = "Material Number";

		ResultDefinition rd = new ResultDefinition(<yourMainTableId>);;
		
		FieldId field = <someFieldFromYourRepository>;
		rd.add(field); 
		// add some additional fields you want to select here ...
		
		FieldSearchDimension searchDimension = new FieldSearchDimension(field);
		TextSearchConstraint searchString =	new TextSearchConstraint(materialNumber, TextSearchConstraint.SOUNDS_LIKE);

		search.addSearchItem(searchDimension, searchString);

		RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(<yourConnection>);
		limitingCommand.setSession(<yourSession>);
		limitingCommand.setResultDefinition(rd);

		limitingCommand.setSearch(search);
		limitingCommand.setPageSize(10);
		try {
			limitingCommand.execute();
			RecordResultSet rs = limitingCommand.getRecords();
		catch(Exception e){
			e.printStackTrace();
		}

If you need more help, let me know

Best regards,

Martin

Former Member
0 Kudos

Thanks

Can it be done using the first MDM API MDM4J?

Thanks