Is it possible to query the index for a TermEnum for all fields in
the index instead of just ?
Thanks,
John
Is it possible to query the index for a TermEnum for all fields in
the index instead of just ?
Thanks,
John
On Apr 9, 2007, at 10:52 AM, John B. wrote:
Is it possible to query the index for a TermEnum for all fields in
the index instead of just ?
Err, I meant to write: “instead of just a single field”
On Apr 9, 2007, at 10:52 AM, John B. wrote:
Is it possible to query the index for a TermEnum for all fields in
the index instead of just a single field?
Anyone have any experience with this? Judging from past discussion on
this list it seems like IndexReader#terms doesn’t get used very much.
John
On Apr 12, 2007, at 9:25 AM, David B. wrote:
def print_all_terms(index) index.field_infos.each do |field_info| field = field_info.name index.reader.terms(field).each {|term, freq| puts "#
{field}:#{term}"}
end
end
David-- thanks, this example is very helpful, but one strange
problem: it seems that FieldInfo does not have a ‘name’ method, and
as far as I can tell there is no way to access the name of the field
represented. What am I missing?
Thanks,
John
On Apr 13, 2007, at 11:02 AM, John B. wrote:
one strange problem: it seems that FieldInfo does not have a ‘name’
method, and
as far as I can tell there is no way to access the name of the field
represented. What am I missing?
I just upgraded to the newest ferret, and now .name works.
Thanks (again),
John
On 4/11/07, John B. [email protected] wrote:
On Apr 9, 2007, at 10:52 AM, John B. wrote:
Is it possible to query the index for a TermEnum for all fields in
the index instead of just a single field?Anyone have any experience with this? Judging from past discussion on
this list it seems like IndexReader#terms doesn’t get used very much.
Here is an example looping over all the terms in an index;
require 'rubygems'
require 'ferret'
def print_all_terms(index)
index.field_infos.each do |field_info|
field = field_info.name
index.reader.terms(field).each {|term, freq| puts
“#{field}:#{term}”}
end
end
index = Ferret::I.new
[
{:one => 'one', :two => 'one two three'},
{:three => 'some knew terms', :four => 'the fourth field'}
].each {|doc| index << doc}
print_all_terms(index)
Hope that helps.
Dave
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs