[ 
https://issues.apache.org/jira/browse/LUCENE-4126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13292344#comment-13292344
 ] 

Chris Male commented on LUCENE-4126:
------------------------------------

Good question.  

Currently specifying your own FieldType means you have to use {{Field}} rather 
than {{StringField}} or {{TextField}} as neither of them accept a FieldType.  
This is messy and basically the same problem that LUCENE-4101 is fixing for 
storing.  Hmm..

In relation to the the copy constructor issue, for scenario #1 currently users 
could do:

{code}
FieldType myNewFieldType = new FieldType(TextField.TYPE_STORED);
myNewFieldType.setStoreTermVectors(true);
{code}

With the copy constructor removed, they would need to do:

{code}
FieldType myNewFieldType = new FieldType();
myNewFieldType.setIndexed(...);
myNewFieldType.setStored(...);
... // set other properties
myNewFieldType.setStoreTermVectors(true);
{code}

In the current case the user can easily rely on the pre-existing type and just 
change the property they're interested in.  In their code it would be clear 
what was changed since no other properties need to be set.  At the same time 
any changes to the pre-existing type would flow into their type without them 
being notified and they cannot scan over their code and see exactly what 
properties are set for a field, they'd have to look up the definition.

With the copy constructor removed, we make changing a property more of a task 
for the user since they would need to define all the properties themselves.  
Yet at the same time they would be protected from any changes to pre-existing 
types and they could see in their code exactly what properties were set.  But 
it also wouldn't be so easily to see which property was specifying changed.

I'm not really sure what's best, what do you think?
                
> Remove FieldType copy constructor
> ---------------------------------
>
>                 Key: LUCENE-4126
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4126
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Chris Male
>             Fix For: 4.0, 5.0
>
>
> Currently FieldTypes can be created using new FieldType(someOtherFieldType) 
> which copies the properties and allows them to then changed.  This reduces 
> readability since it hides what properties someOtherFieldType has enabled.  
> We should encourage users (and ourselves) to explicitly state what properties 
> are enabled so to prevent any surprises. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to