To access dimension search results, use
ENEQueryResults. containsDimensionSearch() (Java) and
ENEQueryResults. ContainsDimensionSearch(), as shown in
examples in this topic.
If a valid dimension search request has been made, the following method
calls for the query result object will evaluate to
true:
However, regardless of how the dimension search request is created to control the number of dimension value results returned, the same objects and methods are used to access those results.
Any matching dimension values are organized by dimension (or dimension list, in the compound dimension search case), and each specific match contains methods to access other values that describe the hierarchy of that dimension value within the dimension.
For this reason, the results are actually dimension locations instead of dimension values. Dimension locations contain a single dimension value, as well as a list of ancestor dimension values.
For example, if a resulting dimension value is
merlot, it will not only be returned in the
Wine Types dimension, but it will be contained in
a dimension location that contains the dimension value
red, because
red is an ancestor of
merlot.
Example 68. Java example
The following code sample in Java shows how to access dimension search results:
ENEQuery usq = new ENEQuery(request.getQueryString(), "UTF-8");
// Set query so that compound dimension search is enabled
usq.setDimSearchCompound(true);
ENEQueryResults qr = nec.query(usq);
// If query results object contains dimension search results
if (qr.containsDimensionSearch()) {
// Get dimension search results object
DimensionSearchResult dsr = qr.getDimensionSearch();
// Get results grouped by dimension groups
DimensionSearchResultGroupList dsrgl = dsr.getResults();
// Loop over result dimension groups
for (int i=0; i < dsrgl.size(); i++) {
// Get individual result dimension group
DimensionSearchResultGroup dsrg =
(DimensionSearchResultGroup)dsrgl.get(i);
// Get roots for dimension group
DimValList roots = dsrg.getRoots();
// Loop over dimension group roots
for (int j=0; j < roots.size(); j++) {
// Get dimension root
DimVal root = (DimVal)roots.get(j);
// Display dimension root
%><%= root.getName() %><%
}
// Loop over results in group
for (int j=0; j< dsrg.getTotalNumResults(); j++) {
// Get individual result
DimLocationList dll = (DimLocationList)dsrg.get(j);
// Loop over dimlocations in result
for (int k=0; k<dll.size(); k++) {
// Get individual dimlocation from result
DimLocation dl = (DimLocation)dll.get(k);
// Get ancestors list
DimValList ancs = dl.getAncestors();
// Loop over ancestors for results
for (int l=0; l < ancs.size(); l++) {
// Get ancestor and display its name
DimVal anc = (DimVal)ancs.get(l);
%><%= anc.getName() %> > <%
}
%><%= dl.getDimValue().getName() %><%
}
}
}
}
Example 69. .NET example
The following code sample in .NET shows how to access dimension search results:
ENEQuery usq = new ENEQuery(queryString, "UTF-8");
// Set query so that compound dimension search is enabled
usq.DimSearchCompound = true;
ENEQueryResults qr = nec.Query(usq);
// If query results object contains dimension search results
if (qr.ContainsDimensionSearch()) {
// Get dimension search results object
DimensionSearchResult dsr = qr.DimensionSearch;
// Get results grouped by dimension groups
DimensionSearchResultGroupList dsrgl = dsr.Results;
// Loop over result dimension groups
for (int i=0; i < dsrgl.Count; i++) {
// Get individual result dimension group
DimensionSearchResultGroup dsrg =
(DimensionSearchResultGroup)dsrgl[i];
// Get roots for dimension group
DimValList roots = dsrg.Roots;
// Loop over dimension group roots
for (int j=0; j < roots.Count; j++) {
// Get dimension root
DimVal root = (DimVal)roots[j];
// Display dimension root
%><%= root.Name %><%
}
// Loop over results in group
for (int k=0; k< dsrg.TotalNumResults; k++) {
// Get individual result
DimLocationList dll = (DimLocationList)dsrg[k];
// Loop over dimlocations in result
for (int m=0; m<dll.Count; m++) {
// Get individual dimlocation from result
DimLocation dl = (DimLocation)dll[m];
// Get ancestors list
DimValList ancs = dl.Ancestors;
// Loop over ancestors for results
for (int n=0; l < ancs.Count; n++) {
// Get ancestor and display its name
DimVal anc = (DimVal)ancs[n];
%><%= anc.Name %> > <%
}
%><%= dl.DimValue.Name %><%
}
}
}
}

