PHP MySQL Match()反对()全文搜索不适用于某些关键字

时间:2016-11-24 13:47:44

标签: php mysql

我是php开发人员,我的MySQL全文搜索有问题。

这是我的查询

select distinct j.jobid,headline,company,country,state,city,location,
date_format(str_to_date(posted_dt, '%m-%d-%Y %H:%i:%s' ), '%M %d, %Y') posted_dt,joblinks 
from jobs j 
left join job_filters jf on jf.jobid = j.jobid 
left join job_emptype_map em on j.jobid = em.jobid 
left join job_sub_emptype_map sem on em.jobid = sem.jobid and em.emp_type = sem.emp_type 
where status=1 
And MATCH (headline,description,pri_skills,company) AGAINST ('java developer' IN natural language MODE) > 1 
And MATCH (location,country,state,city,zipcode,other_loc) AGAINST ('california, United States' WITH QUERY EXPANSION ) > 1 
order by str_to_date(posted_dt,'%m-%d-%Y %H:%i:%s') DESC limit 0,25

我通过上述查询获得了正确的结果。但它正在采取(显示行0 - 24(总共25个,查询花了50.6951秒。)

当我更改关键字" ui developer"而不是" java开发人员"然后我得到0结果

如果我检查关键字" ui developer"有了相似的功能,我就会得到结果。

我不明白为什么匹配功能仅适用于某些关键字,以及为什么我的托管计划是云时需要花费太多时间。

1 个答案:

答案 0 :(得分:0)

我现在正在使用云服务器计划,我已使用类似功能更新了我的查询,现在我的查询是......

select distinct j.jobid,headline,company,country,state,city,location,date_format(str_to_date(posted_dt, '%m-%d-%Y %H:%i:%s' ), '%M %d, %Y') posted_dt,joblinks, (select count(distinct j.jobid) as jobcount from jobs j left join job_filters jf on jf.jobid = j.jobid left join job_emptype_map em on j.jobid = em.jobid left join job_sub_emptype_map sem on em.jobid = sem.jobid and em.emp_type = sem.emp_type where status = 1 and (concat(headline,' ',description,' ',pri_skills,' ',company) like '%java programer%' ) And ( country like '%United States%' ) ) jobcount from jobs j left join job_filters jf on jf.jobid = j.jobid left join job_emptype_map em on j.jobid = em.jobid left join job_sub_emptype_map sem on em.jobid = sem.jobid and em.emp_type = sem.emp_type where status=1 and (concat(headline,' ',description,' ',pri_skills,' ',company) like '%java programer%' )And ( country like '%United States%' ) order by str_to_date(posted_dt,'%m-%d-%Y %H:%i:%s') DESC limit 0,25   

我在上面的查询之间写了选择查询的分页,上面的查询得到了很好的结果,但是花了太多时间, 请注意:我的工作表有大约50,000多条记录