Chapter 5. Introducing OmniFind Discovery Edition APIs 83
Example 5-11 shows the source code that uses the result from the previous
search, creates a new query object, sets up the refined search, and executes the
search.
Example 5-11 Refine search result by executing a search within the previous result
String queryState = mainResultSet.getResolvedQueryState();
Query followupQuery = connector.createQuery(queryState);
followupQuery.setEnableSearchWithin(true);
followupQuery.setText("stainless steel");
results = followupQuery.execute();
After you execute the search, you can get the search result and display it as
shown in Example 5-9 on page 79.
The output of this new program includes only items that contain both the terms
spoon and stainless steel.
We include the complete source code of this program as the additional materials
for this book. Refer to Appendix A, “Additional material” on page 271 for
download instructions.
5.5 Running a complex search
In the previous examples of this chapter, we search for a particular word or
phrase. Using OmniFind Discovery Edition APIs, you can also use other types of
search. In this section, we explain different types of search constraints and show
how you can combine the search conditions to do complex searches.
5.5.1 Constraints
A constraint is a condition that items must satisfy in order to be in the result of a
query. Constraint is an abstract class, which means that a Constraint object can
only be instantiated as a subclass of Constraint. Each subclass of Constraint is
for a specific type of constraint. Different types of constraint are applicable to
different types of features.
84 Getting Started with Commerce Module for OmniFind Discovery Edition
Table 5-2 shows a list of constraints that you can use to compare features with
certain values.
Table 5-2 Constraint types and descriptions
Constraint type Description
Bool Constrains a feature to be true, or constrains it to be false.
DateTime.Eq Constrains a feature to be a particular date.
DateTime.Gt Constrains a feature to be later than a particular date.
DateTime.Gte Constrains a feature to be no earlier than a particular date.
DateTime.Lt Constrains a feature to be earlier than a particular date.
DateTime.Lte Constrains a feature to be no later than a particular date.
DateTime.Neq Constrains a feature not to be a particular date.
DateTime.Range Constrains a feature to be between two particular dates.
Enumerated.Equals Constrains a feature to be a particular string value.
Enumerated.InList Constrains a feature to be one of a particular list of string
values.
Enumerated.NotEquals Constrains a feature not to be a particular string value.
Enumerated.NotInList Constrains a feature not to be one of a particular list of string
values.
Null Constrains a feature to be null, or constrains it to be non-null.
Numeric.Eq Constrains a feature to be a particular numeric value.
Numeric.Gt Constrains a feature to be greater than a particular numeric
value.
Numeric.Gte Constrains a feature to be no less than a particular numeric
value.
Numeric.Lt Constrains a feature to be less than a particular numeric
value.
Numeric.Lte Constrains a feature to be no greater than a particular
numeric value.
Numeric.Neq Constrains a feature not to be a particular numeric value.
Numeric.Range Constrains a feature to be between two particular numeric
values.

Get Getting Started with Commerce Module for OmniFind Discovery Edition Customization 101 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.