How to simply display the index

I’ve read the O’reilly short cut and I can’t figure out how to display
the index for testing purposes and view documents and fields.

Also, I’m planning on creating an index of www html documents. Is there
a preference between using the ferret file system and a mysql database?

Anyone?

Just to provide more information - I want to make sure that the index is
getting generated the way that I want it to be, and so I figured that
the best way to check that would be to examine the index itself.

Any help would be greatly appreciated.

Ben - Thanks, this helps. From your response, I gather that people don’t
really examine the index itself. How then, do people typically test to
make sure that they have the correct index structure and that documents
are getting added to the index correctly? Suppose I want to add document
titles to a ‘title’ field. How does one generally confirm that that’s
happening?

Appreciated.

On 2007-10-02, at 5:14 AM, Eggman Eggman wrote:

Anyone?

Just to provide more information - I want to make sure that the
index is
getting generated the way that I want it to be, and so I figured that
the best way to check that would be to examine the index itself.

I’m not quite sure how we can help you. But maybe as a start,
take a look at the index by using the ferret-browser … starting
from 0.14 on, you’ll have a ferret-browser script that you can
start by pointing it to an index … like that:

bash$ ferret-browser my/index/directory
[2007-10-02 08:56:52] INFO WEBrick 1.3.1
[2007-10-02 08:56:52] INFO ruby 1.8.6 (2007-03-13) [i686-darwin8.10.1]
[2007-10-02 08:56:52] INFO WEBrick::HTTPServer#start: pid=1780
port=3301

then use your browser on http://localhost:3301 to examine
you index.

Ben

Well… i do something like that:

http://bugs.omdb.org/browser/trunk/test/unit/movie_ferret_index_test.rb
http://bugs.omdb.org/browser/trunk/test/unit/person_ferret_test.rb

but i don’t test each ferret fields separately … i guess
that depends on your app … i just test some critical fields … but
not everything …

Ben

Is there no way to open the index files and view them in a text editor
or something? If you’re using a mysql database and you want to view all
the data, you can just export it to an sql file and open it with a text
editor…

Not sure what exactly you’re trying to do, but I keep this handy for
small test cases. I’m always moding it to fit the current need so
you’ll need to tailor it to print the desired fields over a certain
portion of the index:

def usage(message = nil)
puts message if message
puts "ruby #{File.basename(FILE)} "
exit(1)
end

usage() if ARGV.size != 2
usage(“Index ‘#{ARGV[0]}’ doesn’t exist.”) unless
File.directory?(ARGV[0])
$index_dir, $print_number = ARGV

index = Index.new(:path => $index_dir)
0.upto(1238) do |i|
puts index[i][:docID]
end

puts index[$print_number.to_i].load
index.close()

In your example, you still have to specify what data you want to see.

I’m looking for a way to view all the documents and fields in the index
without setting any constraints. The indexer creates files in the index
directory and I was hoping that I could just open one with a text editor
and view the source code, but that doesn’t seem to work.

False Icon wrote:

Not sure what exactly you’re trying to do, but I keep this handy for
small test cases. I’m always moding it to fit the current need so
you’ll need to tailor it to print the desired fields over a certain
portion of the index:

def usage(message = nil)
puts message if message
puts "ruby #{File.basename(FILE)} "
exit(1)
end

usage() if ARGV.size != 2
usage(“Index ‘#{ARGV[0]}’ doesn’t exist.”) unless
File.directory?(ARGV[0])
$index_dir, $print_number = ARGV

index = Index.new(:path => $index_dir)
0.upto(1238) do |i|
puts index[i][:docID]
end

puts index[$print_number.to_i].load
index.close()

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs