How does ReversedWildcardFilterFactory speed up wildcard searches?

☆樱花仙子☆ 提交于 2019-12-11 02:55:27

问题


The Solr docs say:

solr.ReversedWildcardFilterFactory

A filter that reverses tokens to provide faster leading wildcard and prefix queries. Add this filter to the index analyzer, but not the query analyzer. The standard Solr query parser will use this to reverse wildcard and prefix queries to improve performance...

How does it do that though?

Since all the tokens run through the ReversedWildcardFilterFactory, does it store all the tokens in reverse? (That seems silly to me)

Or, does it store all the tokens normally and the reversed tokens and then run through an index list roughly twice as long when querying? (Presumably that's still much faster than searching using a leading *)

Part of why I'm confused is that in the example schema.xml from Solr, they do the following:

<copyField source="*_en" dest="text_en_index"/>
<copyField source="*_en" dest="text_rev_index"/>

where text_rev_index uses a ReversedWildcardFilterFactory. If the ReversedWildcardFilterFactory stores both the forward and reversed tokens, I'm not sure why they would copy these fields to both the forward and reversed dest fields.


回答1:


From https://docs.lucidworks.com/display/lweug/Wildcard+Queries:

The Lucid query parser will detect when leading wildcards are used and invoke the reversal filter, if present in the index analyzer, to reverse the wildcard term so that it will generate the proper query term that will match the reversed terms that are stored in the index for this field.



来源:https://stackoverflow.com/questions/30597947/how-does-reversedwildcardfilterfactory-speed-up-wildcard-searches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!