ruby on rails - Using ThinkingSphinx, How to query min and max weight -


i want retrieve min(weight()) , max(weight()) using thinkingsphinx. tried this:

results = work.search(             'example', :ranker => "expr('sum((4*lcs+2*(min_hit_pos==1)+exact_hit)*user_weight)*1000+bm25*20')",             :select => 'min(weight()) min_weight, max(weight()) max_weight') results.context[:panes] << thinkingsphinx::panes::weightpane 

which translates sphinx expression:

select min(weight()) min_weight, max(weight()) max_weight  `work`  match('example')  limit 0, 20  option ranker=expr('sum((4*lcs+2*(min_hit_pos==1)+exact_hit)*user_weight)*1000+bm25*20') 

if run sphinx expression above against sphinx directly works, work.search call errors:

undefined method `constantize' nil:nilclass 

after looking @ code base, see error related not having sphinx_internal_class in :select clause , further this, understand problem because thinkingsphinx wants query activerecord etc.

so question:

is possible thinkingsphinx return raw sphinx query results , avoid querying activerecord after sphinx query?

as pointed out here:

perform standard ts search, use ‘raw’ middleware set (which doesn’t translate sphinx results activerecord objects):

results = model.search ‘foo’, :middleware =>               thinkingsphinx::middlewares::raw_only 

so changing gave me raw results:

results = work.search(         'example', :ranker => "expr('sum((4*lcs+2*(min_hit_pos==1)+exact_hit)*user_weight)*1000+bm25*20')",         :select => 'min(weight()) min_weight, max(weight()) max_weight'),         :middleware => thinkingsphinx::middlewares::raw_only 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -