Dealing with Search Results

Similar to the requirement to convert Cúram key structs to CuramQuery objects, CuramDocument s returned from searches also need to be converted to Cúram structs to be used in the application.

The SearchServiceConnector search method returns results in the form of a SearchServerResults object. This consists of a list of CuramDocument s, and each CuramDocument consists of a list of CuramField s. A utility class called curam.core.impl.util.CuramDocToResultStruct is provided to convert between CuramDocuments and Cúram structs.

static java.lang.Object convert(CuramDocument document, 
     java.lang.Object structObj, 
     java.util.HashMap dictionary)

This method takes a CuramDocument and a struct instance (via the parameter structObj). For each Field in the CuramDocument, the method attempts to find an attribute in the struct of the same name and datatype. A struct containing all mapped values is returned, this should be cast to a struct of the correct type.

If the names of the attributes of your struct do not correspond to the names of the Fields you have defined for your Search Service (see Field and name), then you can define a mapping between them using the dictionary parameter. The mapping is from the Field names in the Search Service to the attribute names in the struct - simply add the pairs of strings to the HashMap, with the name of the Field as the key and the name of the struct attribute as the value. The convert function will then match Field names to attribute names using this HashMap

Note: Note that the attributes in your results struct whose names correspond to Fields in your document must have simple Cúram types, and not be aggregated structs.