我的dsl如下:
{"query": { "bool":{"filter":{"bool":{"must":[{"term" : { "ALL" :"iwc" }},{"term" : { "ALL" :"wca" }},{"term" : { "ALL" :"cae" }},{"term" : { "ALL" :"aeg" }},{"term" : { "ALL" :"egs" }},{"term" : { "ALL" :"gsp" }},{"term" : { "ALL" :"spd" }},{"term" : { "ALL" :"pds" }},{"term" : { "ALL" :"dse" }},{"term" : { "ALL" :"sex" }},{"term" : { "ALL" :"exw" }},{"term" : { "ALL" :"xwt" }},{"term" : { "ALL" :"wth" }},{"term" : { "ALL" :"thq" }},{"term" : { "ALL" :"hqu" }},{"term" : { "ALL" :"qut" }},{"term" : { "ALL" :"utu" }},{"term" : { "ALL" :"tur" }},{"term" : { "ALL" :"urf" }},{"term" : { "ALL" :"rfv" }},{"term" : { "ALL" :"fvk" }},{"term" : { "ALL" :"vkp" }},{"term" : { "ALL" :"kpm" }},{"term" : { "ALL" :"pma" }},{"term" : { "ALL" :"map" }},{"term" : { "ALL" :"apc" }},{"term" : { "ALL" :"pcz" }},{"term" : { "ALL" :"czz" }}]}}}}}
1. nextdoc耗时较多如何优化?2. 我加了filter,理论上是不评分的,为什么还有builder_scorer的开销?
1 个回复
hanbj
赞同来自: Merrizee
ConstantScoreQuery,lucene会对query进行重写,BooleanQuery会构造一个score对象树,也就是说BooleanQuery还是会对文档打分的,只是外层的ConstantScoreScore统一返回0
你可以包装每个查询用ConstantScore查询,不需要放在fliter里面,另外filter也会缓存,如果缓存的数据量很大,在构建缓存的bit时很耗时