Banner logo

hosted by

What is JavaMatch, compared to...

What is JavaMatch, compared to a search engine?

A search engine is typically used to search on the internet / intranet for documents with a certain text or image. JavaMatch searches inside the Java Virtual Machine for classes that match certain criteria.

The query language supported by a search engine (such as Google) is typically fixed, and limited to a small set of operations. JavaMatch, as an engine, provides a more extensive set of search options. An application may provide a user interface that reduces the vast amount of options to the subset that is relevant for its target domain, or to those queries that are easily understood by the applications' target audience.

What is JavaMatch, compared to SQL?

If you compare the functionality of JavaMatch with SQL, you'll see a couple of differences:

  • SQL is row-based, JavaMatch is object-oriented
  • SQL returns all rows that exactly match your query, and returns them in the order they are encountered in the database. JavaMatch finds out which objects best match your query, and returns their top 10, in ascending order
  • SQL has a limited set of query operators, JavaMatch's queries can be extended to target a specific domain
  • SQL executes the query inside the database, and returns the results. JavaMatch retrieves all data from the underlying data storage mechanism, and performs the matching in the Java runtime environment

What is JavaMatch, compared to my own search algorithm?

I don't know your search algorithm, but JavaMatch uses reflection to specify its queries. It can be applied to any domain, and any data structure. You own query mechanism might be more domain-specific, and can therefore be optimized better.

How, when and where to use

Why hasn't this been implemented before?

Usually, large amounts of data are kept in a database instead of in memory (although the Prevayler project proves memory is also an option). Now that object relational mapping tools are gaining popularity, matching of objects in memory also becomes more interesting.

How about performance?

JavaMatch retrieves all data from the database. For some kinds of queries, this happens even twice. Furthermore, the data is compared using reflection. So, JavaMatch is (at least theoretically) slow. But... Many databases aren't really that big. A couple of thousand objects shouldn't cause too many problems. If you have a very large database, the mechanism doesn't prevent a hierarchical scheme, with a distributed database. I guess that won't be yet in release 1.0, but feel free to ask if you want to hear my ideas about this. (or if you want to contribute).

I only want exact matches. How can I get them?

Exact matches can be specified using the QuerySet.addRequiredQuery(). However, if you only want exact results from your database, plain SQL might be a better alternative, as it is executed inside the database. That causes less (processing and communication) overhead.