heroku上的sunspot_solr错误?(sunspot_solr error on heroku?)
我在我的rails应用程序中使用
'sunspot_rails', '~> 2.0.0.pre.120415'
进行Solr搜索并将其部署在heroku上(两个单独的应用程序)。 它在一个应用程序上工作正常,但在其他应用程序上抛出错误。我检查了heroku环境,发现 - 一个应用程序在雪松堆栈上,ruby版本是1.9.2p290。 (工作正常)另一个在竹堆上,红宝石版是1.9.2p180(抛出错误)
那么,这是ruby版本问题还是heroku堆栈问题? 开发环境中的Ruby版本是1.9.2p290。
错误
$ heroku run rake sunspot:reindex Running rake sunspot:reindex attached to terminal... up, run.8567 rake aborted! uninitialized constant Sunspot::Adapters::Registry::Forwardable /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:310:in `<class:Registry>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:309:in `<module:Adapters>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:34:in `<module:Sunspot>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:1:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:18:in `block in <top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `each' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot/rails.rb:1:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot_rails.rb:6:in `<top (required)>' /app/config/application.rb:7:in `<top (required)>' /app/Rakefile:4:in `require' /app/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)
I'm using
'sunspot_rails', '~> 2.0.0.pre.120415'
for Solr search in my rails app and deploy it on heroku (two separate application). It's working fine on one application but throw error on other.I have checked the heroku environment and found that - one app is on cedar stack and ruby version is 1.9.2p290. (Working fine) other one is on bamboo stack and ruby version is 1.9.2p180 (throw error)
So, Is this the ruby version problem or heroku stack problem ? Ruby version on development environment is 1.9.2p290.
Error
$ heroku run rake sunspot:reindex Running rake sunspot:reindex attached to terminal... up, run.8567 rake aborted! uninitialized constant Sunspot::Adapters::Registry::Forwardable /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:310:in `<class:Registry>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:309:in `<module:Adapters>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:34:in `<module:Sunspot>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:1:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:18:in `block in <top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `each' /app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot/rails.rb:1:in `<top (required)>' /app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot_rails.rb:6:in `<top (required)>' /app/config/application.rb:7:in `<top (required)>' /app/Rakefile:4:in `require' /app/Rakefile:4:in `<top (required)>' (See full trace by running task with --trace)
原文:https://stackoverflow.com/questions/13952162
最满意答案
如果只是大小写不敏感的'in_'语句:
from sqlalchemy import func q = session.query(Detail).filter( func.lower(Detail.sellers).in_(map(str.lower, names)) )
否则,如果你想要有多个“ilike”陈述,
from sqlalchemy import or_ conditions = [] for name in names: conditions.append(Detail.sellers.ilike('%{}%'.format(name))) q = session.query(Detail).filter( or_(*conditions) )
我没有测试过,如果它不起作用,我可以编辑它。
If it's just about the case insensitive 'in_' statement:
from sqlalchemy import func q = session.query(Detail).filter( func.lower(Detail.sellers).in_(map(str.lower, names)) )
Otherwise, if you wanted to have multiple 'ilike' statements,
from sqlalchemy import or_ conditions = [] for name in names: conditions.append(Detail.sellers.ilike('%{}%'.format(name))) q = session.query(Detail).filter( or_(*conditions) )
I haven't tested it, in case it didn't work, I can edit it.
相关问答
更多-
如何在sqlalchemy ORM查询中传递不相似的运算符(how to pass a not like operator in a sqlalchemy ORM query)[2023-07-29]
只是否定过滤器: MyModel.query.filter(sqlalchemy.not_(Mymodel.name.contains('a_string'))) Just negate the filter: MyModel.query.filter(sqlalchemy.not_(Mymodel.name.contains('a_string'))) -
使用literal()可以绕过自动类型处理(或使用type_参数强制自己的处理literal() : Task.description.like(literal("%some pattern%")) It's possible to get around automatic type processing (or force your own with type_ argument) using literal(): Task.description.like(literal("%some pattern ...
-
https://www.postgresql.org/docs/current/static/functions-json.html 检查运营商列表 - 没有~~ - ILIKE不能用于json。 您必须将json转换为文本: t=# select '{ "tag" : ["as","bs","cs"] }'::json::text ilike '%as%'; ?column? ---------- t (1 row) 或使用本地运算符: t=# select ('{ "tag" : ["as","b ...
-
如果您将每个与KeywordsToProducts匹配的KeywordsToProducts加入到Keywords您可以收集并比较它们: var query = from p in Products join kp in KeywordsToProducts on p.ProductId equals kp.ProductId into kpj let kws = (from kp in kpj join kw in Keywords on kp.Keywor ...
-
您的查询看起来很好。 我认为你的查询不起作用的唯一原因是“coutry”字段使用默认分析器,其中术语是低级的并存储在索引中。 如果你得到以下查询的预期结果,我的怀疑是正确的。 要解决此问题,您可以将查询更改为我在下面提到的查询,也可以更改映射以使“国家/地区”字段不进行分析。 "bool": { "must": [ { "range": { "age": { "from": 40, ...
-
如果只是大小写不敏感的'in_'语句: from sqlalchemy import func q = session.query(Detail).filter( func.lower(Detail.sellers).in_(map(str.lower, names)) ) 否则,如果你想要有多个“ilike”陈述, from sqlalchemy import or_ conditions = [] for name in names: conditions.append(Detai ...
-
LdapQueryBuilder和LikeFilter的文档声明您必须在查询中明确使用* ,因此如果您正在寻找以Mike开头的用户,则必须在过滤器语法中使用Mike* ; 它只是一个简写,允许您指定通配符而无需转义它。 所以: public List
findByName(String Name) { LdapQuery query = query().where("objectclass").is("top") .and("Name").like(Name + "*"); ... -
如果您只想使其更安全,您仍然可以在param占位符中进行插值: session.execute("""UPDATE ... WHERE server.provider_id IN (%s)""" % ",".join("?" * len(provider_ids)), provider_ids) 的? 是占位符,根据您使用的数据库驱动程序的参数paramstyle而有所不同。 否则,最简单的方法是将其转换为session.query或update().where()构造。 If all you want ...
-
这不是一个答案,而是一个评论。 但显然我不能在评论中使用代码块。 如果您不知道,可以使用多个filter或filter_by将它们链接在一起,如下所示: Item.query.filter(Item.a < 5).filter(Item.b > 6).all() 因此,您可以将返回值临时存储为变量(它实际上是Query一个对象),稍后再使用它。 q = Item.query.filter(Item.a < 5) if some_condition_value: q = q.filter(Item ...
-
我能用这段代码解决这个问题。 礼貌Github问题: SQLAlchemy-Util问题(253) from sqlalchemy.sql import expression from sqlalchemy_utils.types.ltree import LQUERY custom_lquery = '*.some.pattern' Model.query.filter(Model.path.lquery(expression.cast(custom_lquery, LQUERY))).all( ...