Forum: Ferret about WildQuery !

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ferret user (Guest)
on 2006-06-01 07:53
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
David B. (Guest)
on 2006-06-01 08:07
(Received via mailing list)
On 6/1/06, ferret user <removed_email_address@domain.invalid> 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 slow

This 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 fast

I'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
ferret user (Guest)
on 2006-06-01 08:17
i just want search a substring
like :  search 'te' in 'ddte  fssfsf'
but i cannot find a better way~
thanks
David B. (Guest)
on 2006-06-01 08:43
(Received via mailing list)
On 6/1/06, ferret user <removed_email_address@domain.invalid> wrote:
> i just want search a substring
> like :  search 'te' in 'ddte  fssfsf'
> but i cannot find a better way~
> thanks

If 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.
ferret user (Guest)
on 2006-06-01 08:57
Thanks David B.
i try using 'test*' instead of '*test*'
thanks a lot
This topic is locked and can not be replied to.