[
https://issues.apache.org/jira/browse/LUCENE-8870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16872601#comment-16872601
]
Namgyu Kim commented on LUCENE-8870:
------------------------------------
Thank you for your reply! [~jpountz] :D
When I wrote a patch, the biggest advantage that I think is the FieldType
conversion for Numeric types.
Of course, it is not recommended way(it is already mentioned Expert in
Javadoc), but it can give users FieldType customization.
ex)
Currently NumericDocValuesField does not support the option for stored.
So users need to add a separate StoredField.
If we provide this patch, the user can get the characteristics of
NumericDocValuesField and StoredField in a single field.
{code:java}
FieldType type = new FieldType();
type.setStored(true);
type.setDocValuesType(DocValuesType.NUMERIC);
type.freeze();
Document doc = new Document();
Field field = new Field("number", 1234, type);
doc.add(field);
indexWriter.addDocument(doc);
{code}
After that, we can use methods such as
{code:java}
Sort sort = new Sort();
sort.setSort(new SortField("number", SortField.Type.INT));
{code}
and
{code:java}
doc.get("number");
{code}
in the "number" field.
> Support numeric value in Field class
> ------------------------------------
>
> Key: LUCENE-8870
> URL: https://issues.apache.org/jira/browse/LUCENE-8870
> Project: Lucene - Core
> Issue Type: New Feature
> Reporter: Namgyu Kim
> Priority: Major
> Attachments: LUCENE-8870.patch
>
>
> I checked the following comment in Field class.
> {code:java}
> // TODO: allow direct construction of int, long, float, double value too..?
> {code}
> We already have some fields like IntPoint and StoredField, but I think it's
> okay.
> The test cases are set in the TestField class.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]