You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by antony <an...@gmail.com> on 2021/04/20 18:28:03 UTC
StoreField with long value using python3
Hello,
Anyone help me how to use StoredField(String name, long value). Its not
working because there is no 'long integer' in Python 3.
I am using Python 3.8.0 and pylucene 8.6.1.
Source code:
cdate = int(datetime.datetime.now().strftime("%Y%m%d%H%M"))
print(1, cdate)
doc = Document()
doc.add(LongPoint('cdatetime', cdate))
doc.add(StoredField('cdatetime', cdate))
print(2, doc)
writer.addDocument(doc)
writer.commit()
writer.close()
Output:
1, cdate = 202104202312
2, Document<LongPoint <cdatetime:202104202312>
*stored<cdatetime:240739400>*>
Thanks,
Antony
--
Sent from: http://pylucene-users-developers-list.2474766.n2.nabble.com/
Re: StoreField with long value using python3
Posted by Andi Vajda <va...@apache.org>.
On Tue, 20 Apr 2021, antony wrote:
>
> Hello,
>
> Anyone help me how to use StoredField(String name, long value). Its not
> working because there is no 'long integer' in Python 3.
Not sure that's the problem.
It looks like the StoredField(int) overload is called before the
StoredField(long). This is a bug.
A possible workaround would be to edit the StoredField class to add a
constructor accepting a java.lang.Long() and then passing it a Long(cdate) ?
especially since all it does is set Object fieldsData on Field anyway...
I didn't try this out...
Andi..
>
> I am using Python 3.8.0 and pylucene 8.6.1.
>
> Source code:
>
> cdate = int(datetime.datetime.now().strftime("%Y%m%d%H%M"))
>
> print(1, cdate)
>
> doc = Document()
> doc.add(LongPoint('cdatetime', cdate))
> doc.add(StoredField('cdatetime', cdate))
>
> print(2, doc)
>
> writer.addDocument(doc)
> writer.commit()
> writer.close()
>
> Output:
>
> 1, cdate = 202104202312
>
> 2, Document<LongPoint <cdatetime:202104202312>
> *stored<cdatetime:240739400>*>
>
>
> Thanks,
> Antony
>
>
>
> --
> Sent from: http://pylucene-users-developers-list.2474766.n2.nabble.com/
>