0

I need execute 2 queries by one queue and passing result of first query to IF expression of other query as well as ordinary MySQL queries.

As example, I try pass @average variable into second query:

SET @average=(SELECT AVG(weight()) avg_rank FROM common WHERE  match('query text') OPTION ranker=expr('sum(word_count)*100 + sum(lcs*user_weight)*100 + bm25 + sum(exact_order)*200');

SELECT *, weight() as rank, 2000 * exp( - 9.594E-5 * abs(1486121357 - _rank_date)/1000) AS date_rank, IF(_importance > @average,_importance,0) AS importance_rank, (rank + date_rank + importance_rank) as total_rank FROM common WHERE match('query text') OPTION ranker=expr('sum(word_count)*100 + sum(lcs*user_weight)*100 + bm25 + sum(exact_order)*200')

But i had parse error. How i can do it?

Daniyal
  • 129
  • 2
  • 9

1 Answers1

0

Don't think you will be able to do that in Sphinx as such.

The application would just have to run the first query, capture the value, and write it explicitly into the second query.

But it also seems that the expression jsut modifies what is returned anyway (rather than say reordering or filtering results), so rather than getting sphinx to compute the IF expressions, just do it in the application.

barryhunter
  • 20,886
  • 3
  • 30
  • 43