Sphinx或coreseek做全文索引相关备忘三

今天遇到之前部署的全文检索昵称在查询时不能精确匹配的问题,如查询138111000,则会将1、3、8等数字全部拆分,所匹配的用户和所期望的结果不一致,存在的昵称‘用户138111000’并没在查询结果中,多次使用sphinxapi.jar进行不同参数的查询实验,最终的方案为:

(1)查询的模式为SPH_MATCH_PHRASE

(2)所查询的关键字用英文单引号括起来,再传递给服务端,这样,查询的结果就正确了

具体命令为:

 java -jar sphinxapi.jar -h 192.168.1.2 -p 9312 -ph '138111000' 
sphinxapi.jar可使用的命令参数:
-h, --host <HOST>	connect to searchd at host HOST
-p, --port		connect to searchd at port PORT
-i, --index <IDX>	search through index(es) specified by IDX
-s, --sortby <CLAUSE>	sort matches by 'CLAUSE' in sort_extended mode
-S, --sortexpr <EXPR>	sort matches by 'EXPR' DESC in sort_expr mode
-a, --any		use 'match any word' matching mode
-b, --boolean		use 'boolean query' matching mode
-e, --extended		use 'extended query' matching mode
-ph,--phrase		use 'exact phrase' matching mode
-g, --groupby <EXPR>	group matches by 'EXPR'
-gs,--groupsort <EXPR>	sort groups by 'EXPR'
-l, --limit <COUNT>	retrieve COUNT matches (default: 20)
-ga, --geoanchor <LATATTR> <LONGATTR> <LAT> <LONG>
			set anchor for geodistance
--select <EXPRS>	select the listed expressions only
 
 

猜你喜欢

转载自bsr1983.iteye.com/blog/1987302
今日推荐