Richard
Richard

Reputation: 65530

Faceted search: ElasticSearch/Solr or a simple database query?

Forgive this super basic question, from a search newbie.

I want to implement a site that makes use of faceted search. For example, it's a site with a database of hotels, and I want to allow users to search for hotels within a price range, with a swimming pool, with either three or four stars.

Clearly I can return results to users with a simple database query.

Should I use ElasticSearch or Solr to implement this instead of using a database query? If so, why?

Upvotes: 2

Views: 1986

Answers (1)

Geert-Jan
Geert-Jan

Reputation: 18895

Yes you should use ES or Solr. Reasons: primarily performance and the ability to change (think config) 'types of faceting' easily.

Faceting is no small feat and although you could do it with a RDBMS, to do it fast requires hard thinking. Why do it yourself if you can use the gazillions of hours Solr / ES (+ Lucene) teams have worked to optimize it.

As for the 'types of faceting' I mentioned:

  1. perhaps you want to do hierarchical faceting. Select price-category > display smaller price categories. How are the bucketed: fixed range, evenly distributed, etc. Solr / ES provide these options from within a config.
  2. Perhaps instead you implement price-faceting with a slider with min/max handles? Do you want to display the nr of hotels while you slide (histogram/facetstats in SOlr / ES)
  3. While you've faceted on price, perhaps you still want to know the min and max-value of the priceslider as if you DIDN't filter on price. This is needed if you want to be able to draw the slider-handles proportionally. (see my question on SO as part of considering a switch from Solr to ES: Elasticsearch: excluding filters while faceting possible? (like in Solr) )
  4. faceting on stars? Perhaps you want to show the best price per stars-facet if the user would select that star (again histogram/ stats)

Seriously, don't even consider doing the above with a RDBMS. You'll go insane.

Hope that helps, and yes I'm familiar with the domain :)

Additional questions, just ask.

Upvotes: 6

Related Questions