2

I have indexed a site using Nutch and now I am searching the index using the Zend Lucene library.

I've actually pulled the Zend libraries into Codeigniter but it is all Zend doing the work.

I can display the title, score and url fine but I can't find the name of the field to display the content from the page.

So far I have the following code

$index = new Zend_Search_Lucene('C:\nutch\nutch-0.9\my-search\index');

$query = $this->input->post('searchQuery');

$hits = $index->find($query);

echo "<p>Index contains " . $index->count() . " documents.</p>";

echo "<p>Search for '" . $query . "' returned " . count($hits) . " hits</p>";

foreach ($hits as $hit) 
{

  echo "<h4>" . $hit->title . "</h4>";

  echo "<p><b>Score:</b> " . sprintf('%.2f', $hit->score) . "</p>";

  echo "<p><b>Url:</b> " ."<a href='" . $hit->url . "'>" . $hit->url. "</a></p>";

}

Can anyone help out with the name of the field to display the content or a content summary?

Thanks

Charles
  • 50,943
  • 13
  • 104
  • 142
ianckc
  • 1,716
  • 5
  • 18
  • 33
  • Don't use backslashes for paths, even on windows. Always use forward slashes - PHP and actually even the windows api functions understand them. When using backslashes you'd have to escape them! While \n isn't a newline in a single-quoted string it's still dirty to use unescaped backslashes. – ThiefMaster Nov 22 '10 at 15:58
  • Thanks, this is only at the testing stage on my local machine and is nowehere near production ready code. Even with the forward slashes it doesn't solve the index field names question. – ianckc Nov 22 '10 at 16:01
  • Were you able to get it to work? Was there any index version issues building the index with Nutch and reading with Zend Lucene ? – haknick Feb 01 '11 at 18:00
  • I've never managed to get this working. I haven't had much time to spend on it though. If I do I'll post here. – ianckc Feb 08 '11 at 14:22

1 Answers1

2

I don't know the nutch index format, but whenever I need to check a lucene index I use Luke - Lucene Index Toolbox

It allows you to open an index directory, browse fields and run queries. Very helpful if you're using an unfamiliar index.

Neil Aitken
  • 7,856
  • 3
  • 41
  • 40
  • Thanks for the link. I have had a very brief look at Luke and it seems like the sort of thing I am looking for. – ianckc Nov 22 '10 at 16:05