0

I'm trying to wildcard a field using Zend search Lucene.

$index = Zend_Search_Lucene::open("/data/my_index1");

$doc = new Zend_Search_Lucene_Document();

$doc->addField(Zend_Search_Lucene_Field::Text('date',$date->format('dmY')));

$index->addDocument($doc);

$index->updateIndex();

$hits  = $index->find('2012*');

The last line is not working because my date is something like 02062012. If i try with $hits = $index->find('*2012*'); is not working either.

Any idea?

hakre
  • 193,403
  • 52
  • 435
  • 836
Gabriel Muñumel
  • 1,876
  • 6
  • 34
  • 57
  • You should check if the date is indexed properly. Some analyzers won't tokenize numbers and dates. You should browse your index with luke to see whether your index contains the expected terms. – dbrumann Jun 02 '12 at 16:05
  • I think the index is ok because if i try with `$hits = $index->find('02062012');` is working as it should. – Gabriel Muñumel Jun 02 '12 at 16:21
  • Have you tried `$index->find('0206*');`? I'm not sure, but I think using the asterisk in your query doesn't work, because it is looking for terms which contain 2012 followed by something. – dbrumann Jun 03 '12 at 11:20

1 Answers1

0

You should also verify that your search configuration allows a leading '*', as that is not the default in Lucene.

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29