Hi Adam,

Definitely something is wrong. 

Your code looks good.
Could you provide your index for testing? If yes, please create JIRA issue and 
attach index to it. Or send it to me.


I expect that the problem is in the 'locality:auckland' term processing 
(possibly it has very low selectivity).

Please also let me know which FW version do you use? There was a problem with 
array_intersect_key() performance (ZF-1975), but it was fixed in ZF 1.0.2

With best regards,
   Alexander Veremyev. 

> -----Original Message-----
> From: Adam Ratcliffe [mailto:[EMAIL PROTECTED]
> Sent: Sunday, November 11, 2007 12:10 AM
> To: Zend Framework General
> Subject: [fw-general] Zend_Search_Lucene - Performance is terrible, am I
> doing something wrong?
> 
> Hi
> 
> I'm indexing a table in a relational database with 153002 rows, the
> database contains location-based data.
> 
> The size of the index produced from this table was initially 60Mb,
> subsequently I've reduced the fields indexed to 4: 2 with type 'Text'
> and 2 with type 'UnIndexed' - reducing the index size to 17Mb.
> 
> The computer I'm testing on is a G4 PowerBook, 1.5Ghz processor with
> 1.25Gb RAM.
> 
> Searching against 2 fields 'name' and 'locality', and accessing the
> Document instance for the 1st 10 results only, takes 15 seconds.
> Using an equivalent Java Lucene implementation takes < 300ms.
> 
> See below for the Java and PHP code used for each test:
> 
> <?php
> 
> require_once 'Zend/Search/Lucene.php';
> 
> Zend_Search_Lucene::setDefaultSearchField('name');
> Zend_Search_Lucene_Search_QueryParser::setDefaultOperator
> (Zend_Search_Lucene_Search_QueryParser::B_AND);
> 
> $indexPath = '/tmp/poi_idx';
> 
> $index = new Zend_Search_Lucene($indexPath);
> 
> $search = 'william pickering locality:auckland';
> 
> $start = microtime(TRUE);
> 
> $hits = $index->find($search);
> 
> for($i = 0; $i < 10; $i++) {
>      echo $hits[$i]->name . "\n";
> }
> 
> echo "Query \"$search\" executed in " . round((microtime(TRUE) -
> $start), 2) . "s\n";
> 
> ?>
> 
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.queryParser.QueryParser;
> import org.apache.lucene.search.Hits;
> import org.apache.lucene.search.IndexSearcher;
> import org.apache.lucene.search.Query;
> 
> public class Searcher {
> 
>       static String indexPath = "/tmp/poi_idx";
> 
>       public static void main(String[] args) throws Exception {
>               String search = "william pickering locality:auckland";
> 
>               IndexSearcher s = new IndexSearcher(indexPath);
>               QueryParser parser = new QueryParser("name", new
> StandardAnalyzer());
>               parser.setDefaultOperator(QueryParser.AND_OPERATOR);
>               Query q = parser.parse(search);
> 
>               long start = System.currentTimeMillis();
> 
>               Hits h = s.search(q);
>               for(int i = 0; i < 10; i++) {
>                       Document d = h.doc(i);
>                       System.out.println(d.get("name"));
>               }
> 
>               System.out.println("Query \"" + search + "\" executed in " +
> (System.currentTimeMillis()- start) + "ms");
>       }
> 
> }
> 
> Indexing Code Excerpt
> --------------------------------
> 
>      private function addToIndex($record) {
>          if(isset($record['id'])) {
>              $doc = new Zend_Search_Lucene_Document();
>              $doc->addField(Zend_Search_Lucene_Field::UnIndexed
> ('poi_id', $record['id']));
>              $nameField = Zend_Search_Lucene_Field::Text('name',
> $record['name']);
>              $nameField->boost = 2;
>              $doc->addField($nameField);
>              $doc->addField(Zend_Search_Lucene_Field::Text
> ('locality', join(' ', array($record['suburb'],
> 
>                 $record['town'],
> 
>                 $record['district'],
> 
>                 $record['region'],
> 
>                 ))));
>              $doc->addField(Zend_Search_Lucene_Field::UnIndexed
> ('class', 'Poi'));
>              $this->index->addDocument($doc);
>          }
>      }
> 
> Cheers
> Adam
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.15.31/1129 - Release Date:
> 13.11.2007 21:22
> 
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.31/1129 - Release Date: 13.11.2007 
21:22
 

Reply via email to