Banner logo

hosted by

What is JavaMatch?

JavaMatch is an engine that can search inside a runtime Java data structures, and look for objects that best match the criteria that you specify. JavaMatch is a generic match engine, not targeted at a specific domain. It can be applied to any runtime data structure, and the extensive query mechanism allows for highly customizable tuning of your searches. JavaMatch can be integrated with object- relational mapping tools. This allows you to match inside databases.


JavaMatch's functionality compared to "normal" database searching can be described by using an analogy:

If you search for something in Google, you don't just see the pages that exactly match your search query, you'll also get the results that best match the search query (unless you use the "+"-syntax).
JavaMatch provides this Google-like functionality, but then applied to a Java data structure: It looks for the objects that best match the query: Out of the entire data set, it returns the top-10 (or more, if you specify so) of the best matching objects.

Example: Queries

Nice those stories, but how does it work in practice? Let me give you an example:

Let's suppose there is an application that keeps an inventory of used cars. This application has a class Car, with methods getBrand(), getPrice(), ... to retrieve the brand, price, ....
If I want to find a certain car, I can specify the following query:

QuerySet query = new QuerySet();
query.addRequired(new StringEquals("brand", "BMW"));
query.addPreferred(new LessThan("price", 10000));
query.addPreferred(new Range("buildYear", 1997, 2002));
query.addPreferred(new LessThan("mileage", 80000));

List allCars = carData.getAllCars();
MatchResult matchResult = matchEngine.executeQuery(query, allCars);


When you execute this query, the match engine might return objects with the following data:

Match value brand buildYear price mileage
1.00 BMW 1998 $7,900.00 44,000
1.00 BMW 2002 $9,999.00 25,000
1.00 BMW 1997 $6,400.00 62,000
0.75 BMW 2002 $13,000.00 35,000
0.75 BMW 2000 $3,800.00 120,000
0.50 BMW 2003 $15,500.00 12,000

As you can see in row 1 to 3, the match engine first returns the objects that exactly match the criteria. This is the same data that you get when you execute a similar SQL query. Row 4 to 6 are different: they show the objects that don't match exactly, but the objects that best match the query.

What's more?

The queries that you see in the example above are just a small subset of the queries that JavaMatch provides. In the documentation section, you'll find the following different kinds of queries:

  • Queries: Various string, number and boolean queries
  • Relative matching: Finding minimum and maximum values in the data set
  • QuerySets: Used to merge multiple required and/or preferred subqueries
  • Extensions: Defining custom queries

Other features provided by JavaMatch are: