background preloader

Lucene

Facebook Twitter

Compass: Integrate Search into your apps. Motivation In many applications, there is a user requirement to search or look up domain entities. It is either required as an entry point into the application or as a mechanism for filling in forms. Typically, this is solved either by navigation (presenting the domain hierarchically so the user can locate and choose an item) or by a search form (presenting the user with a form containing a number of fields they can search on). The reality is that both approaches are sub-optimal from a usability perspective. The navigational approach quickly becomes slow and cumbersome when there are large numbers of entities.

Also, the user usually knows exactly what entity they are looking for, yet they are forced to navigate the hierarchy to find it. The search-form approach is also limited by the number of fields that can be searched on. When faced with the task of implementing a traditional, multi-field search form, most applications turn to SQL. Introducing Compass Compass Core API // ... Compass Gps. QueryParser Rules.

Suppose you are searching the Web for pages that contain both the words java and net but not the word dot . What if search engines made you type in something like the following for this simple query? BooleanQuery query = new BooleanQuery (); query . add ( new TermQuery ( new Term ( "contents" , "java" )), true , false ); query . add ( new TermQuery ( new Term ( "contents" , "net" )), true , false ); query . add ( new TermQuery ( new Term ( "contents" , "dot" )), false , true ); That would be a real drag.

Thankfully, Google, Nutch, and other search engines are friendlier than that, allowing you to enter something much more succinct: java AND net NOT dot This article assumes you have some basic understanding of Lucene, including building and querying an index. First we'll see what is involved to use QueryParser in an application. Using QueryParser Using QueryParser is quite straightforward.

Field-selection qualifiers are discussed in the query syntax section. Now, let's parse an expression: j*v? Tutorial : Lucene integration with Spring and Hibernate. Code_poet. Wouldn't it be great to be able to use a powerful search engine on your business objects? Searching is becoming THE preferred way for user's to find their data. Emerging applications like Google Desktop and Beagle have embraced the new mantra of user's to "Search, Don't Sort".

User's don't want to be forced to organize their data into limiting categories or folders, or to scroll around applications to find the data they are looking for. Even common GUI practices like table sorting are considered an eye sore compared to a snappy search box. I have experienced the same expectation when working with my D20 datasets. My goal was create a simple search framework to handle simple searching for the majority of my domain objects out of the box.

Collection results = searcher.search(DefaultSkill.class, "knowledge arc*"); The first piece of the puzzle was to figure out how to create an index with my persistent objects.