Вопрос

I am trying to pick the right indexing/search solution for my Rails 4 app. So far I have considered Sunspot (Solr) and Thinking Sphinx (Sphinx), but from reading the documentation on both of them, I am not sure whether they can satisfy my use case.

For simplicities sake, let's say I have "Sheep" and "Herd"s in my model. Every sheep belongs to exactly one herd.

I would like to present my user with a query interface that allows to specify criterions on sheep and herds. The search results shall be grouped by herd. A part of the criterions should work as facets, provding the user with the information how many sheeps/herds he will find when he specifies a certain value for a facet.

QUERY INTERFACE

Sheep criterions
    Name: _____________
    Color
        [ ] Black (14)
        [X] White (36)

    Age: Between [ ] and [ ]

Herd criterions
    Description contains: _____________
    Country
        [ ] Australia (12)
        [ ] Germany (10)
        [ ] Sealand (1)

RESULTS

+ Herd 37 (Australia) with 12 matching sheep (15 total)
+ Herd 10 (Germany) with 20 matching sheep (27 total)
- Herd 42 (Sealand) with 1 matching sheep (1 total)
    Sad lonely white sheep
+ Herd 11 (Germany) with 3 matching sheep (7 total)

So I would like to do a faceted search on sheep, group them by herd and then do another faceted search on the results. Is this possible in either Solr, Sphinx or yet another search engine that can be combined with rails?

I considered duplicating the herd attributes into the sheep - at least for the indexing - but it seemed that this would produce an enormeus overhead.

Это было полезно?

Решение

Yes, can be done in Solr. Most likely adding the herd attributes to the sheep would be the better way, so you could do this in a single query. You have some overhead anyway to get the data into Solr, so you can as well put everything in a single index. I have used Solr faceting for far more complex problems.

Sphinx too has facets, though I didn't use it, so can't say exactly if they would work, but from the documents it seems there are no big differences to Solr.

Another option would be ElasticSearch. As Solr it's built on the Apache Lucene engine. When I decided for Solr Elastic wasn't fully featured, but by now they have caught up and I read very good things about it in blogs. Actually considering to switch the project.

There are some NoSQL solutions that work similar to facets. Though they may lack some other features of those full text search engines.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top