when i use WildQuery ,i was so slowly!! the query string like this : ''name|title:*test*'' i search field ''name'' and ''title'' what include string ''test'' it worked ,but too slow but when i use query string like this : ''name|title:test*'' or ''name|title:*test'' it worked fast my english is poor,thanks -- Posted via http://www.ruby-forum.com/.
On 6/1/06, ferret user <sunshine82 at yeah.net> wrote:> when i use WildQuery ,i was so slowly!! > the query string like this : ''name|title:*test*'' > i search field ''name'' and ''title'' what include string ''test'' > it worked ,but too slowThis is not surprising. To run this query Ferret needs to check every single term in the "title" field.> but when i use query string like this : ''name|title:test*''This should be a lot faster. With this query Ferret can scan straight to the point in the index where terms start with the string test and scan through them one by one until they no longer start with test and it''s finished. Actually, this query gets optimized to a PrefixQuery.> or ''name|title:*test'' it worked fastI''m quite surprised this is much faster. I''d expect it to be a little faster but not by much. Maybe WildCard query can be optimized a little. I''ll look into it but don''t expect much. The index isn''t really built for this type of query. Do you need to run this query often? What exactly are you trying to do? I might be able to come up with a better way to do it. Cheers, Dave
i just want search a substring like : search ''te'' in ''ddte fssfsf'' but i cannot find a better way~ thanks -- Posted via http://www.ruby-forum.com/.
On 6/1/06, ferret user <sunshine82 at yeah.net> wrote:> i just want search a substring > like : search ''te'' in ''ddte fssfsf'' > but i cannot find a better way~ > thanksIf you just want to have the ability to search for different substrings like this then WildQuery is your best option for now. Are you on Windows? If you are then it''ll be a lot faster when I finally get the extension compiled for Windows. If you are already using the C extension then the speed you see will probably be the best you can get. If you are running this query a lot you have a couple of options. For shorter strings such as titles and names you could right a custom Analyzer which will break up a term like this; fastest search -> (fastest astest stest test est) (search earch arch rch) where the brackets represent one term position. Now you can do test* instead of *test* or ear* instead of *ear*. In the example I stopped at strings of length 3 but you can keep going if you want to search for *t*. This will make the index considerable larger so if you are searching really large strings then you should probably read up about Suffix Arrays. Cheers, Dave PS: look at lib/ferret/analysis/analyzers.rb to see how to implement a custom analyzer.