php - How to do order by case when on sphinx? -
how can set column priority sphinx search? in custom mysql code, following codes. how can re-code sphinx search?
$orderby = "order case when substring_index(n.eser_adi, '/', 1) '% $termsasil %' 1 when substring_index(n.eser_adi, '/', 1) '$terms' 2 when n.konu_basliklari '% $termsasil %' 3 when n.konu_basliklari '$terms' 4 when yazar_adi '% $termsasil %' 5 when yazar_adi '$terms' 6 when n.isbn '% $termsasil %' 7 when n.isbn '$terms' 8 when yer_numarasi '$termsasil%' 9 else 10 end asc";
well technically can put expression in select section
sphinxql> select id,if(col=2,1,2) mysort index order mysort asc
note, there isnt case statement, use if() same effect.
but there no or indeed substring_index function, wouldn't translate over.
however there search terms, manipulate query effect calculated weight. can use field-weights adjust relative weights.
sphinxql> select id index match('$terms (@eser_adi ^terms | @eser_adi ^terms | @eser_adi "^terms$" | @konu_basliklari $termsasil)')
http://sphinxsearch.com/docs/current.html#api-func-setfieldweights
Comments
Post a Comment