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
>>>
>>>
>>
>
>
>
--
View this message in context:
http://www.nabble.com/Zend_Search_Lucene%3A-No-Results-tf2414738s16154.html#a7229926
Sent from the Zend Framework mailing list archive at Nabble.com.