Sorry this is entire code

ireader = IndexReader.open(dir1)
fields = MultiFields.getFields(ireader)
terms = fields.terms("Doc")
termsEnumvar = terms.iterator(None)
termsref = BytesRefIterator.cast_(termsEnumvar)
term_dict={}
try:
 while (termsref.next()):
  termval = TermsEnum.cast_(termsref)
  fg = termval.term().utf8ToString()
  freq =  termval.docFreq()
  term_dict[fg]=freq
except:
 print 'error in term_dict'


On Tue, Feb 4, 2014 at 12:54 PM, Premraj Narkhede <
premraj.narkh...@dolcera.com> wrote:

> Hi Andi
>
> Thanks for your help
>
> we tried following solutions and it worked
>
> term_dict={}
> try:
>  while (termsref.next()):
>   termval = TermsEnum.cast_(termsref)
>   fg = termval.term().utf8ToString()
>   freq =  termval.docFreq()
>   term_dict[fg]=freq
> except:
>  print 'error in term_dict'
>
>
> On Mon, Feb 3, 2014 at 2:22 PM, Premraj Narkhede <
> premraj.narkh...@dolcera.com> wrote:
>
>> Thanks
>>
>> We will quickly try this and come back with results.
>>
>>
>> On Mon, Feb 3, 2014 at 1:43 PM, Andi Vajda <va...@apache.org> wrote:
>>
>>>
>>> > On Feb 2, 2014, at 23:09, Premraj Narkhede <
>>> premraj.narkh...@dolcera.com> wrote:
>>> >
>>> > I am using 4.5.1
>>> >
>>> >
>>> >> On Mon, Feb 3, 2014 at 12:38 PM, Andi Vajda <va...@apache.org> wrote:
>>> >>
>>> >>
>>> >>>> On Feb 2, 2014, at 22:51, Premraj Narkhede <
>>> premraj.narkh...@dolcera.com>
>>> >>> wrote:
>>> >>>
>>> >>> Hi
>>> >>>
>>> >>> I am trying to get to terms in Index using following code.
>>> >>>
>>> >>> But I keep getting error saying termsEnum doesnt have "next" function
>>>
>>> Try casting your termsEnum object to a BytesRefIterator via:
>>>   BytesRefIterator.cast_(termsEnum)
>>> then call next() on the result.
>>>
>>> http://lucene.apache.org/core/4_5_1/core/org/apache/lucene/index/TermsEnum.html
>>>
>>> You shouldn't have to do that, since TermsEnum implements that
>>> interface. Maybe you found a bug. See if there is a PyLucene unit test that
>>> uses TermsEnum and how it's done there (not near computer with code to
>>> check myself at the moment).
>>>
>>> Andi..
>>>
>>> >>>
>>> >>> Please help
>>> >>
>>> >> What version of PyLucene are you using ?
>>> >>
>>> >> Andi..
>>> >>
>>> >>>
>>> >>> ireader= DirectoryReader.open(dir1)
>>> >>> terms = SlowCompositeReaderWrapper.wrap(ireader).terms("Doc");
>>> >>> termsEnum = terms.iterator(None)
>>> >>> while termsEnum.next():
>>> >>> fg=termsEnum.term()
>>> >>> print fg
>>> >>>
>>> >>> Premraj
>>> >>
>>>
>>
>>
>

Reply via email to