Searching Multiple Collections


The following code sample assumes that you want to find similar images of a car from several media collections. In this example, we:


open two disk-based collections

search each of the collections

combine the results of the two searches

sort the combined results


// create the two MediaCollection objects and open the two collections

MediaCollection mc01 = Eve.newMediaCollection();

MediaCollection mc02 = Eve.newMediaCollection(); directoryPath1 ); directoryPath2 );


// read in a media object containing the car picture

MediaObject source = Eve.newMediaObject();

source.loadFrom ("\\images\\carpicture.jpeg.edf");


// set up a 50-50 color and region search

SearchParameters parameters = Eve.newSearchParameters();




// perform the two searches using the same source object and parameters

SearchResults results1[] =,parameters);

SearchResults results2[] =,parameters);


// add the results of the two searches together

SearchResults worker = Eve.newSearchResults();

SearchResults finalResults[] = worker.append(results1,results2);


// sort the combined results by similarity

finalResults = worker.similaritySort(finalResults);


// truncate the results after the first 32 entries

// (results are sorted in descending order of similarity)

finalResults = worker.chop(finalResults,32);



At this point you have a single array with (possible) entries from each collection. To determine which collection generated a particular result, use the SearchResults.getCollectionName() method.