Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-6815

Issue with Collections in field value while indexing a document.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.9
    • None
    • clients - java
    • None

    Description

      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.

      Attachments

        1. SolrIndexingTest.java
          0.6 kB
          Kiran Kumar Dontam

        Activity

          People

            Unassigned Unassigned
            kiran214 Kiran Kumar Dontam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: