GSoC Journey: Week1

Rushi Chaudhari
Jun 2, 2019 · 2 min read

After the one month of community bonding, the actual coding period is started on 27th May. In the community bonding period, I talked with the mentors and set milestones for each week.

Following are the main goals I archived in this week😁 :

  1. Perform changes in the Person class, so it will create Lucene indexes.
  2. Create a new module’s skeleton and implement PatientLuceneQuery class in the module.
  3. Create Lucene queries for gender and birthdate search with the help of Lucene API.
Image for post
Image for post

What is Lucene and Lucene indexes?

Lucene is a full-text search library in Java which makes it easy to add search functionality to an application or website. Lucene indexes are similar to the inverted index which we normally see in the reference books. In the book’s inverted index, we see that word to page indexing i.e. particular word appears in which pages in the book. In a similar manner, the Lucene library generates the Lucene indexes for the fields present in the database.

Image for post
Image for post

OpenMRS’s Lucene API does not directly use Lucene library, It uses Hibernate search API which internally uses Lucene library.

Image for post
Image for post

For my 1st goal i.e for creating lucence indexes of Person class, I added the @Indexed annotation to the POJO class of Person. Also, I added the @Field annotation to gender and birthdate member of Person class which tells Hibernate to create a Lucene index for Person class with the fields gender and birthdate.

After that, I created a new PatientLuceneQuery class which consists the Lucene queries for searching the Patient with gender and birthdate. The following are the Lucene queries that are built on top of OpenMRS Lucene APIs:

LuceneQuery<Person> luceneQuery = LuceneQuery
.newQuery(Person.class, sessionFactory.getCurrentSession(), query, fields);

DateLuceneQuery<Person> luceneQuery = DateLuceneQuery.newQuery(Person.class, sessionFactory.getCurrentSession(),
query, field);

On the next week I’m will create Lucene queries which help to search patients with range of age. 😁

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store