Implement Lucene Search in Android App – How to make it work

I created an Android app for World Health Organization long ago. I made different kinds of search engines before with full-text indexing. This time I wanted to do something different. I had only 4 days to make the app. They had different kinds of contents like

  1. html
  2. Plain text files
  3. PDF files

And they needed a search engine to search all the contents and show a unified result set ( Showing results in a same page with relevancy ). Now I could implement it in SQLite, but that would mean a lot of task and the gain would be much lesser than a document-based search engine like Apache Lucene.

Read More »

Springboot and MongoDB: Creating indices on inherited properties or fields.

I started writing my first spring and the first springboot application today. The project requires mongodb and mysql as databases. My application’s domain objects are highly hierarchical and we need to make different kinds of search engines for many child classes. So, there needs to be some violations from common patterns like “field shadowing”. Though it’s only for the purpose of data and search layer, it doesn’t affect the object model of the application. So, I needed to change field behavior in subclasses which are different entities or collections in Mongo store. Basically I needed to put a annotation on subclass to enable an index on a field.

Read More »

Writing Effective “Special Case Pattern” and “Null Object Pattern”

Handling null can be problematic in code organization and management. So, there are two very common patterns used by experienced developers now and then. One is “Null object pattern”, where you return an object which states a missing object, and another is “Special Case Pattern”. This article is to “How you can write effective objects for those patterns and why you should use them instead of returning null or throwing exceptions”

Read More »

Associative Array in Java like PHP?

I don’t know how many times I saw this question asked by many PHP developers. It happens when some developer is not developing in Java actively, need to do some quick codes, and does PHP development regularly. Associative arrays are one of the most used feature (or is it the most?) of PHP.

Though collections are basic java features, and why many of PHP developers cannot readily catch that they can use Maps or Properties collections? It’s mainly because of OOP pattern. Java collections are objects. And many PHP developers are too accustomed to using Non-OOP patterns even if they are coding in a object oriented framework like laravel, or symfony, or zend.

Spring bean scopes

I just learned it!

code dweller

When defining a <bean> in Spring, you have the option of declaring a scope for that bean. For example, To force Spring to produce a new bean instance each time one is needed, you should declare the bean’s scope attribute to be prototype. Similar way if you want Spring to return the same bean instance each time one is needed, you should declare the bean’s scope attribute to be singleton.

The Spring Framework supports following five scopes, three of which are available only if you use a web-aware ApplicationContext.

Scope Description
singleton This scopes the bean definition to a single instance per Spring IoC container (default).
prototype This scopes a single bean definition to have any number of object instances.
request This scopes a bean definition to an HTTP request. Only valid in the context of a web-aware Spring ApplicationContext.
session This scopes a bean definition to an…

View original post 33 more words

Spring Collection Injection: How does it actually work

I am learning Java Spring Framework out of personal interest. I am trying to understand how it works. Today I was learning dependency injection in Spring. I started with injecting java collections through xml beans. As you already know, if you want to set a property of primitive type, you need to put exactly the same property name in bean xml definition. I started with that for injecting a List collection named addressList.

Read More »