简体   繁体   中英

Heroku Rails Websolr, sunspot is not free in production?

I've added sunspot gem in my application and tried to send it to production in heroku, but I'm trying to reindex my database, however, I'm getting an error. I did some more digging and I think I have to add websolr as an add-on? This costs $20/month. Is this the only option?

THanks

I've done some more research and found out that there are other options if you don't want to take the websolr path. These other answers are good for some insights, but doesn't give an alternative to what can be used.

For some that's still looking, I suggest taking a look at Elastic Search

Rails Cast has a good tutorial on this as well.

And to use it with heroku, look into Bonsai which gives users a free option.

Hopefully this answer will help those that are also seeking other options than using sunspot gem with solr

Founder of Websolr + Bonsai here (Heroku addons for Solr and Elasticsearch).

Rich's answer is pretty solid, with the exception of the SQL LIKE operator, which I do not recommend. The performance does not scale, and you're either going to sink in a lot more time than you might expect in order to eke out baseline search functionality. End result: a lot of time spent, and unhappy users.

Postgres full text search is a reasonable alternative, though the term analysis and result ranking will be lacking compared to Solr/Elasticsearch as your search traffic starts to grow in production.

You might also consider our sister service, Bonsai, which does offer a free Starter plan. It uses Elasticsearch, which means you'd want to use the official Ruby bindings for Elasticsearch rather than Sunspot.

Lastly, if you already have a production app on Heroku, you are welcome to create more than one index in your account, and share those indexes with your staging/qa and other apps.

Solr on Heroku uses their own add-on, which starts at $20pm:

在此输入图像描述

Although I don't know why it costs up front, and doesn't have a "trial" option like many of the other Heroku Add-ons, there are certain ways around it


Full Text Search

Full text search is what you're performing, and Solr is a tool to make the process much more efficient. Despite being quite DB-expensive, you can use full text searching with Heroku, depending on your DB:

MYSQL

To perform full-text searching on MYSQL, you can simply use the "LIKE" operator with %variable% as your search phrase, like this:

SELECT * FROM `table` WHERE `name` LIKE `%benjamin%`

This basically finds all the records where the name column contains "benjamin" somewhere inside it. This is quite slow

POSTGRESQL

PostgreSQL offers more power in its full text searching, but is nonetheless still quite slow & expensive. You can read more about it here , but with rails, you can use a bunch of gems which do the task for you

We recently used a gem called textacular here: http://firststop.herokuapp.com

Here is the code we used for it:

    #Search
    def self.search(search)
        basic_search(name: search, description: search)
    end

Further Reading

You can see how full text searching works here: Any reason not use PostgreSQL's built-in full text search on Heroku?

I would recommend if you're just getting the foundations established for your app. Afterwards, you can upgrade to a more dedicated solution in the form of Solr et al

Here are

If you want to use the Heroku platform it starts for free, but you have to pay for almost every add-on, extra workers, extra storage, search engine, background tasks, you name it.

For $20/month you could also get a decent VPS, but you would have to install and manage that server by yourself.

As for sunspot/solr on Heroku, I don't think you can do that for free.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM