Refining a Search

 

Your first set of search results may not contain exactly what you want. If this is the case, you'll need to refine your results.

 

The following code:

 

opens a MediaCollection

gets a list of keys from the collection

does a random search

resubmits the fifth item in the result set for another search using the same parameters

 

// make a new MediaCollection object

MediaCollection mc = (MediaCollection) Eve.newMediaCollection();

try

{

    mc.open (directoryName);

}

catch (Exception e)

{

    // handle the exception

}

 

// Get a list of keys from the collection

long keys[] = mediaCollection.getKeys();

 

// Use the third key entry to get a source MediaObject

MediaObject source = mediaCollection.getMediaObject (keys[2]);

// Use this source object for a 50% color/50% region search

SearchParameters parameters = Eve.newSearchParameters();

parameters.setSearch (Eve.COLOR, true, 0.5);

parameters.setSearch (Eve.REGION, true, 0.5);

 

// Perform the search

SearchResults results[] = mediaCollection.search( source, parameters );

 

// To refine the search (for example, to select other entries),

// simply resubmit with one of the previous results

SearchResults refinedResults[] = mediaCollection.search(results[4],parameters);