You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Vamsee Yarlagadda (JIRA)" <ji...@apache.org> on 2015/02/28 09:58:04 UTC

[jira] [Commented] (SOLR-6815) Issue with Collections in field value while indexing a document.

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

Vamsee Yarlagadda commented on SOLR-6815:
-----------------------------------------

bq. 2. If the user wants to add the same value (Collection) to different fields, those fields may get corrupted. Adding more values to one fields will add them to other fields as well. (This is how I found the issue).
I agree. This is certainly a problem. I don't understand why this case was not included in the first place. 

https://github.com/apache/lucene-solr/blob/trunk/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java#L60
This issue can be solved by creating a copy of the collection in setField method. In fact, we can move this section from addField() itself.
Let me know if this makes sense. I can help putting up a patch.




> Issue with Collections in field value while indexing a document.
> ----------------------------------------------------------------
>
>                 Key: SOLR-6815
>                 URL: https://issues.apache.org/jira/browse/SOLR-6815
>             Project: Solr
>          Issue Type: Bug
>          Components: clients - java
>    Affects Versions: 4.9
>            Reporter: Kiran Kumar Dontam
>            Priority: Minor
>         Attachments: SolrIndexingTest.java
>
>
> Issue with {{SolrInputDocument.addField()}} method.
> If this method is called for the first time for a field, it will call {{setField}} method, which calls {{SolrInputField.setValue}}.
> Assume that the value is a Collection in this flow. The value's reference is added to the field in the doc. If we add another value to the same field (using {{addField}}), it will be added to the original collection.
> This is incorrect because we are modifying user's original collection.
> This will break in the following cases:
> 1. If the original collection is unmodifiable. This will throw {{UnsupportedOperationException}} while adding 2nd value.
> 2. If the user wants to add the same value (Collection) to different fields, those fields may get corrupted. Adding more values to one fields will add them to other fields as well. (This is how I found the issue).
> One solution:
> In {{SolrInputField.setValue}} we can always create a new Collection (ArrayList) if the incoming value is a Collection.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org