Solr plugin for the playframework
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Solr plugin for playframework

This plugin is an example plugin I wrote the upcoming playframework cookbook. It is actually pretty raw and lacks severe documentation.

You might want to try it anyway.

Play configuration

You can configure another server than localhost by setting the solr.server property


Solr configuration

  • Add the binary request handler to your configuration
  • Add the searchClass field as string to your configuration (every entity search will use this as a filter!)
  • Id is the unique key

Model configuration

public class User extends SearchModel {
        public String name;
        public String twitter;

As you can see, you either use name of the field as index name or provide it inside of the annotation. This makes it easy for arbitrary attributes without having to add them manually to the solr configuration.


Searches can be fired in your code with a breeze

List<User> users ="byNameAndTwitter", "a*ex", "spinscale*").fetch();

Note that this type of query actually does database queries! If you just need the ids, use

List<String> ids ="byNameAndTwitter", "a*ex", "spinscale*").fetchIds();

You can use start() and limit() to have pagination and decrease database loads

List<User> users ="byNameAndTwitter", "a*ex", "spinscale*").start(10).limit(10).fetch();

Weaknesses and problems

  • Weak index by choosing “models.Entity.$ID”
  • Just POC, no real app tests yet
  • Works only with JPA