Skip to content

Instantly share code, notes, and snippets.

@nz
Last active December 14, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nz/5043495 to your computer and use it in GitHub Desktop.
Save nz/5043495 to your computer and use it in GitHub Desktop.

Hello everyone,

Good news! After seven months of a widely adopted pre-release, Sunspot 2.0.0.pre has just been released as Sunspot 2.0.

  Successfully built RubyGem
  Name: sunspot
  Version: 2.0.0
  File: sunspot-2.0.0.gem

What's new?

The difference between Sunspot 2.0 and Sunspot 1.3 are focused on support for two features which were introduced in Solr 3: official Solr 3 spatial search, and Solr 3 field collapsing. There are a few other changes related to Solr 3, but the new Spatial Search API is what drove the push to Solr 3, and someminor backwards-incompatible changes to its DSL are what necessitated a major version change.

Read on for a brief writeup of the notable changes, and a full changelog toward the end.

Upgraded to Solr 3.5.0

Thank you to Chris Parker for upgrading the bundled version of Solr in the sunspot_solr gem to version 3.5.0. Most of the new features in Sunspot 2.0 rely on Solr 3, and if you're running an index on Solr 1.4 you should definitely upgrade that as soon as possible.

If anyone would like to get the sunspot_solr jars bumped to Solr 3.6.1, I would happily accept that for a quick 2.1 release.

  • Q: Why not Solr 4?
  • A: Getting to that. Read on…

Spatial Search

The need for more robust spatial search is largely what drove Sunspot 2.0 development. Previous versions of Sunspot relied on the solr-spatial-light plugin in Solr 1.4, and then later on client-side geohashing. Both approaches left much to be desired.

Solr 3.1 introduced official Solr support for geospatial search, and Sunspot 2.0 features a slightly updated spatial search DSL which integrates nicely with Solr 3's Spatial Search API.

Shout outs to Eric Tang, Bruno Miranda, and Andy Lindeman for their work on the new Spatial Search DSL in Sunspot 2.0.

Field Grouping

Field Grouping, or "Field Collapsing," is another Solr 3 feature, which lets you collapse multiple matching document into a single row in Solr's response, based on some shared field value.

For an example, consider Google's search results: multiple results from a single website are usually collapsed into a single item on their search result page.

Thanks to Andy Lindeman for the work on this.

Range Facets

Also new in Solr 3 is the ability to create facets from numeric and date ranges.

Post.search do
  facet :average_rating, :range => 1..5, :range_interval => 1
end

TODO: who added this? Jan Ulrich?

Report Your Search Query Time

Jason Weathered contributed a nice Search#query_time method to let you fetch the Solr query time from the response.

TCP Timeouts

Your app only has so long to wait, and sometimes servers like to fail in the form of an infinitely long responses. To help combat this, Rob Di Marco added support for open_timeout and read_timeout configuration options in sunspot.yml.

The Full Changelog

I could go on (and should!) but I've hit my timebox and need to get back to working on other stuff! Here's the full changelog for Sunspot 2.0.0:

  • Adds support for field grouping (Andy Lindeman)
  • Adds support for native geospatial searches and ordering (Eric Tang, Bruno Miranda, Andy Lindeman)
  • Bundled Solr installation (sunspot_solr) is version 3.5.0 (Chris Parker)
  • Adds #query_time method to retrieve the Solr query time in milliseconds (Jason Weathered)
  • Fixes syntax of highlighting when used with nested dismax queries (Marco Crepaldi)
  • Adds ability to nest Sunspot.batch calls (Thorbjørn Hermansen)
  • Adds open_timeout and read_timeout configuration options (Rob Di Marco)
  • Adds offset options to facets (Federico Gonzalez)
  • Adds Retry5xxSessionProxy to retry requests when an internal server error occurs (Nick Zadrozny)
  • Adds support for range queries (Jan Ulrich)
  • Allows custom field names specified with :as to be symbols (David Oliver)
  • Add field exclusion when faceting (Cuong Hoang)

So What's Next for Sunspot?

As mentioned earlier, this prerelease has been sitting around for quite some time. Many people have used it and reported success. So while I've wanted to include a few other changes in 2.0, the code we have now is well worth releasing on its own merit.

The recent release of Solr 4 has helped refocus some of Sunspot's development goals, and many of the changes that 2.0 had been waiting on actually make a lot more sense to include in an upcoming 3.0 release which focuses on integration with Solr 4.

Solr 4

For most use cases, Sunspot should actually be more or less forward-compatible with Solr 4 as of today, if you are willing to mess around a bit with your solrconfig.xml and schema.xml. Solr's official APIs have been remarkably forward-compatible over the years. In fact, if you are a Websolr customer, particularly via Heroku, we plan to start defaulting new Sunspot indexes to run on Solr 4 in the very near future.

Within Sunspot proper, we will want to update the bundled Solr JAR files, so that everyone is using Solr 4 locally, as well as update the stock Solr configurations. While we're updating those configs, there are also a lot of improvements we can make to support popular text analysis features, such as n-gram and linguistic analysis. There are also some features in Solr 3 and 4, such as spellcheck or query filter caching, which integrated or improved within Sunspot proper.

Thank You, Contributors!

Thanks to everyone who helped contribute features to Sunspot 2.0. It's always exciting to see an open source developer community step forward and collectively take ownership of a project.

If there's anyone I missed in this email or the project History.txt, let me know so I can give credit where credit is due.

And thank you all for your patience with myself and other committers as we let the prerelease linger on a bit longer than may have been strictly necessary :-)

Contributors are Always Welcome!

Incidentally, I think I have a lot more opinions these days than hours to implement them! If you're a developer using Sunspot, or even a more junior level developer who wants to start contributing to open source, I'd love to hear from you!

I would love to start providing regular guidance and Solr support to anyone who would like to contribute to Sunspot and help keep things moving forward for this community. Perhaps a semi-regular Google+ Hangout with interested contributors? That seems to have worked out well for other communities.

@semmin
Copy link

semmin commented Feb 27, 2013

Nick, thanks for everything you do on sunspot. sunspot 2.0 was very much expected, primarily for its spatial search improvements. I have indexes with WebSolr on Solr 3.6, can I start using sunspot 2.0 rightaway, or should I migrate my indexes to Solr 4.0 first? And what about Google+ Hangout that you mentioned, I'd love to participate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment