php - fulltext search results showing where most repeated words -


i inserted in web browser , works great, shows me messy results, show me @ top on word or words in search repeated.

i looked online tutorials can not , come messy, not understand why.

right have this:

$sql="select art,tit,tem,cred,info,que,ano,url  contenido match (art,tit,tem,cred,info)  against ('" .$busqueda. "' in boolean mode)  order id desc"; 

there not information on internet refine or optimize searches mysql fulltext. see if experts come through here , learn.

how refine search? thank you.

i think issue you're sorting id.

the fulltext sorts match score calculates, showing stronger matches first. when apply order id desc, loose sort-by-match ordering.

you can see actual score in result set if want by:

select art,tit,tem,cred,info,que,ano,url,       match (art,tit,tem,cred,info)        against ('your term' in boolean mode) score contenido match (art,tit,tem,cred,info)    against ('your term' in boolean mode)     order id desc 

btw: use prepared statements 'your term' portion.

if search string has spaces each term matter, need treat them separate pieces. if it's important have both "mercedes" , "benz":

  • don't: against ('mercedes benz' in boolean mode) <--- means either mercedes or benz
  • do: against ('+mercedes +benz' in boolean mode)

if want have must have first term, optionally second term (ranking higher when both found) do:

 against ('+mercedes benz' in boolean mode) 

here's long list of combinations: https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

and dont forget, rid of order id desc. think you're final query should "mercedes benz"

select art,tit,tem,cred,info,que,ano,url     contenido  match (art,tit,tem,cred,info)    against ('+mercedes benz' in boolean mode); 

yep, freetext in mysql has lot of quirks, play around, you'll hang of it.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -