Java selection method

Use the ENEQuery.setSelection() method for Java implementations.

For Java-based implementations, you set the selection list on the ENEQuery object with the setSelection() method, which has this syntax:
ENEQuery.setSelection(FieldList selectFields)

where selectFields is a list of property or dimension names that should be returned with each record. You can populate the FieldList object with string names (such as "P_WineType") or with Property or Dimension objects. In the case of objects, the FieldList.addField() method will automatically extract the string name from the object and add it to the FieldList object.

During development, you can use the ENEQuery.getSelection() method (which returns a FieldList object) to check which fields are set.

The FieldList object will contain a list of Endeca property and/or dimension names for the query. For details on the methods of the FieldList class, see the Endeca Javadocs for the Presentation API.

Note: The setSelection() and getSelection() methods are also available in the UrlENEQuery class.

Java Select example

The following is a simple Java example of setting an Endeca property and dimension for a navigation query. When the ENEQueryResults object is returned, it will have a list of records that have been tagged with the P_WineType property and the Designation dimension. You extract the records as with any record query.

// Create a query
ENEQuery usq = new UrlENEQuery(request.getQueryString(),"UTF-8");
// Create an empty selection list
FieldList fList = new FieldList();
// Add an Endeca property to the list
fList.addField("P_WineType");
// Add an Endeca dimension to the list
fList.addField("Designation");
// Add the selection list to the query
usq.setSelection(fList);
// Make the MDEX Engine query
ENEQueryResults qr = nec.query(usq);