Hi Smita,

I saw this issue, but had not associated your e-mail with it.

I have tested it with ZF 0.2 just now and it works for both examples.

There were two bugs in the ZF 0.1.5 which affect on searching.
One problem was with a latest term in a dictionary (ZF-207) and another was able to affect on very small indexes (I am not sure, that we had an issue in the issue tracker for this).

Which of these two fixes helped? That is a question :)

Please try ZF 0.2 and I would like to ask you let me know if it helps.


With best result,
   Alexander Veremyev.


smita wrote:
Hi Alexander,

Here is a link to my zend framework trouble ticket....
http://framework.zend.com/issues/browse/ZF-440
And the example below is what I am trying.
INDEX:

<?

require_once 'Zend/Feed.php';

require_once 'Zend/Search/Lucene.php';

$index = new Zend_Search_Lucene('/tmp/indexnew', true); $doc = new Zend_Search_Lucene_Document();
$data = "A field name is used to search by default. It's good idea to place
main document data into this field with this name.";

$id = "22222"; $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $id)); $doc->addField(Zend_Search_Lucene_Field::Text('contents', $data)); $index->addDocument($doc); $doc = new Zend_Search_Lucene_Document();
$data = "Phrase Queries are very flexible and allow to search exact phrases
as well as sloppy phrases 345."; $id = "1111111"; $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $id)); $doc->addField(Zend_Search_Lucene_Field::Text('contents', $data)); $index->addDocument($doc); $index->commit();
?>

SEARCH:

<?php

require_once 'Zend/Search/Lucene.php';

echo "required";

$index = new Zend_Search_Lucene('/tmp/indexnew');

echo "Index contains {$index->count()} documents.\n"; $query = "default";
$hits = $index->find(strtolower($query));

echo "Search for \"$query\" returned " .count($hits). " hits.\n\n";

foreach ($hits as $hit) { echo str_repeat('-', 80) . "--<br>"; echo 'ID: ' . $hit->id ."<br>"; echo 'Score: ' . sprintf('%.2f', $hit->score) ."<br>"; $document = $hit->getDocument(); echo "id--".$document->getFieldValue('id'); echo "".$document->getFieldValue('contents'); }
?>

This was an example I was trying from another forum posting of a developer
and does not work.
Thank you.
-Smita


Alexander Veremyev wrote:
Hi!

Could I ask you to describe your situation a little bit in more details?
:)

With best regards,
    Alexander Veremyev.

smita wrote:
I have had similar issues with searching. Sometimes it works and and
sometimes it just wont find anything. Also it indexes some words and
ignores
others. Any ideas why?


Jan Pieper-2 wrote:
I want to to implement a Lucene based search in my blog but it does not
function. Yesterday morning it works but after I created the index new
nothing works.

--------------------------------------------------------------------------------

$index = new Zend_Search_Lucene($config->search->index, true);
foreach($result as $row)
{
    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::UnIndexed(
        'created', $row['writedate']
    ));
    $doc->addField(Zend_Search_Lucene_Field::Text(
        'title', $row['title']
    ));
    $doc->addField(Zend_Search_Lucene_Field::Text(
        'url', $config->site->url.'blog/entry/'.$row['id']
    ));
    $doc->addField(Zend_Search_Lucene_Field::Text(
        'content', $row['content']
    ));
    $index->addDocument($doc);
}
$index->commit();


--------------------------------------------------------------------------------

The index will be created and I can search in it with Luke
(http://www.getopt.org/luke/) but if I use the ZF-API nothing will be found :(

--------------------------------------------------------------------------------

$index = new Zend_Search_Lucene($config->search->index);
$hits  = $index->find('intergenia');
foreach ($hits as $hit) {
    echo '[' . $hit->score. '] '. hit->title . '<br />';
    echo $hit->url . '<br /><br />';
}

--------------------------------------------------------------------------------

Where is the mistake? Is there a chance to use the GermanAnalyzer?

-- Jan






Reply via email to