# Wildcard trouble

**URL:** <https://www.ruby-forum.com/t/wildcard-trouble/157069>\
**Category:** Ferret\
**Created:** [January 7, 2009, 1:18am UTC](https://www.ruby-forum.com/t/wildcard-trouble/157069 "2009-01-07T01:18:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [January 7, 2009, 1:18am UTC](https://www.ruby-forum.com/t/wildcard-trouble/157069/1 "2009-01-07T01:18:40Z")

</div>

Hi-- I just ran into an odd situation. If I do a search including the  
term:  
c\* - I get 4 hits  
ca\* - I get the same 4 documents  
co\* - I get one new document, not found by c\*

Does anyone know what might be going on, or have suggestions for  
debugging?

Thanks,  
–Paul

–  
Paul L.  
Aquilent, Inc.  
National Library of Medicine (Contractor)

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [February 10, 2009, 10:27am UTC](https://www.ruby-forum.com/t/wildcard-trouble/157069/2 "2009-02-10T10:27:56Z")

</div>

Hi Paul,

On 07.01.2009, at 01:17, Paul L. wrote:

> Hi-- I just ran into an odd situation. If I do a search including  
> the term:  
> c\* - I get 4 hits  
> ca\* - I get the same 4 documents  
> co\* - I get one new document, not found by c\*
> 
> Does anyone know what might be going on, or have suggestions for  
> debugging?

How does your full query look like? Ferret has a built in default  
limit of 512 for the number of terms wildcard queries (and other  
MultiTermQueries) can get expanded to. Any more terms matching your  
criteria will be dropped then, keeping the most relevant 512 terms.  
You can override this value by specifying a max\_terms value when  
constructing the query via the API:

query = WildcardQuery.new(:field, “c\*”,  
:max\_terms =\> 1024)

you might also try monkey patching the  
Ferret::Search::MultiTermQuery::default\_max\_terms method to return  
your custom limit so you dont need to use the query API to construct  
your queries (i.e. with aaf which doesn’t reliably work with query  
objects due to the DRb stuff involved).

It _might_ also be a bug in Ferret - if the above doesn’t help, can  
you reproduce this with a simple test case?

cheers,  
Jens

–  
Jens KrÃ¤mer  
Finkenlust 14, 06449 Aschersleben, Germany  
VAT Id DE251962952  
[http://www.jkraemer.net/](http://www.jkraemer.net/) - Blog  
[http://www.omdb.org/](http://www.omdb.org/) - The new free film database

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [March 2, 2009, 11:33pm UTC](https://www.ruby-forum.com/t/wildcard-trouble/157069/3 "2009-03-02T23:33:19Z")

</div>

Jens,  
I think you are right. There are 932 terms matching c\* in my data  
table.  
(The rest of my query is simple-- just onr or two other terms without  
wildcards). I tried setting the value of default\_max\_terms, but it did  
not  
seem to have any effect. (I think I was setting it correctly, because I  
tried assigning a negative number and it immediately complained.)  
However,  
now that I know what that is doing, I’m not sure I want to increase the  
value.  
Anyway, thank you very much for your help in sorting this out.  
–Paul
