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

SolrDocument and SolrInputDocument should have a common interface

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.5, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      Currently, both share a Map interface (SOLR-928). However, there are many common methods like createField(), setField() etc. that should perhaps go into an interface/abstract class.

      1. SOLR-8339.patch
        8 kB
        Ishan Chattopadhyaya
      2. SOLR-8339.patch
        8 kB
        Ishan Chattopadhyaya
      3. SOLR-8339.patch
        8 kB
        Ishan Chattopadhyaya
      4. SOLR-8339.patch
        6 kB
        Ishan Chattopadhyaya

        Issue Links

          Activity

          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment - - edited

          Is there a historic reason for not having a common interface/abstract class for SolrDocument and SolrInputDocument other than a Map?
          Since having this right now might break backcompat, does it make sense to do this for 6.0?
          Right now, the motivation for doing this is SOLR-8220, but not strictly needed.

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - - edited Is there a historic reason for not having a common interface/abstract class for SolrDocument and SolrInputDocument other than a Map? Since having this right now might break backcompat, does it make sense to do this for 6.0? Right now, the motivation for doing this is SOLR-8220 , but not strictly needed.
          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment -

          It seems there is no backcompat implications. Spoke to Noble Paul offline, and mentioned that there is no backcompat issue with this change as long as any existing method is not deleted or altered.

          Here's a patch adding a SolrDocumentBase as an abstract class which SolrDocument and SolrInputDocument now extend from.

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - It seems there is no backcompat implications. Spoke to Noble Paul offline, and mentioned that there is no backcompat issue with this change as long as any existing method is not deleted or altered. Here's a patch adding a SolrDocumentBase as an abstract class which SolrDocument and SolrInputDocument now extend from.
          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment -

          Updated patch, includes the child document methods common to both the classes as well.

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - Updated patch, includes the child document methods common to both the classes as well.
          Hide
          mkhludnev Mikhail Khludnev added a comment -

          Looked on. Patch seems fine!

          Show
          mkhludnev Mikhail Khludnev added a comment - Looked on. Patch seems fine!
          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment -

          Removed javadocs references using @see annotation. Some how ant was not happy. Those links seemed not all that useful anyway.

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - Removed javadocs references using @see annotation. Some how ant was not happy. Those links seemed not all that useful anyway.
          Hide
          iorixxx Ahmet Arslan added a comment -

          With this change, can we remove org.apache.solr.client.solrj.util.ClientUtils#toSolrInputDocument method? And org.apache.solr.client.solrj.util.ClientUtils#toSolrDocument ?

          Show
          iorixxx Ahmet Arslan added a comment - With this change, can we remove org.apache.solr.client.solrj.util.ClientUtils#toSolrInputDocument method? And org.apache.solr.client.solrj.util.ClientUtils#toSolrDocument ?
          Hide
          shalinmangar Shalin Shekhar Mangar added a comment -

          With this change, can we remove org.apache.solr.client.solrj.util.ClientUtils#toSolrInputDocument method? And org.apache.solr.client.solrj.util.ClientUtils#toSolrDocument ?

          We can deprecate those in 5.x and remove in trunk.

          Ishan Chattopadhyaya - SolrDocument used to be serializable but you have removed that in your patch. Same for SolrInputDocument. That is a compat-break. Can you put that back?

          Show
          shalinmangar Shalin Shekhar Mangar added a comment - With this change, can we remove org.apache.solr.client.solrj.util.ClientUtils#toSolrInputDocument method? And org.apache.solr.client.solrj.util.ClientUtils#toSolrDocument ? We can deprecate those in 5.x and remove in trunk. Ishan Chattopadhyaya - SolrDocument used to be serializable but you have removed that in your patch. Same for SolrInputDocument. That is a compat-break. Can you put that back?
          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment -

          Thanks Shalin Shekhar Mangar. Added the Serializable to the base class.

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - Thanks Shalin Shekhar Mangar . Added the Serializable to the base class.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1717654 from shalin@apache.org in branch 'dev/trunk'
          [ https://svn.apache.org/r1717654 ]

          SOLR-8339: Refactor SolrDocument and SolrInputDocument to have a common base abstract class called SolrDocumentBase. Deprecated methods toSolrInputDocument and toSolrDocument in ClientUtils.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1717654 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1717654 ] SOLR-8339 : Refactor SolrDocument and SolrInputDocument to have a common base abstract class called SolrDocumentBase. Deprecated methods toSolrInputDocument and toSolrDocument in ClientUtils.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1717657 from shalin@apache.org in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1717657 ]

          SOLR-8339: Refactor SolrDocument and SolrInputDocument to have a common base abstract class called SolrDocumentBase. Deprecated methods toSolrInputDocument and toSolrDocument in ClientUtils.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1717657 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1717657 ] SOLR-8339 : Refactor SolrDocument and SolrInputDocument to have a common base abstract class called SolrDocumentBase. Deprecated methods toSolrInputDocument and toSolrDocument in ClientUtils.
          Hide
          shalinmangar Shalin Shekhar Mangar added a comment -

          Thanks Ishan!

          Show
          shalinmangar Shalin Shekhar Mangar added a comment - Thanks Ishan!
          Hide
          jugaji Juan José added a comment -

          When upgrade Apache Solr from version 4.10 to 5.0.0, the parse serialization is not working from SolrDocument class to json.
          we use library com.fasterxml.jackson.core:jackson-databind:2.5.4 for json parsing. We are getting this exception:

          org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError
          org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302)
          org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977)
          org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
          org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
          org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
          org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

          causa raíz
          java.lang.StackOverflowError
          com.fasterxml.jackson.databind.type.HierarchicType.getRawClass(HierarchicType.java:74)
          com.fasterxml.jackson.databind.type.TypeFactory._doFindSuperInterfaceChain(TypeFactory.java:1009)
          com.fasterxml.jackson.databind.type.TypeFactory._findSuperInterfaceChain(TypeFactory.java:1004)
          com.fasterxml.jackson.databind.type.TypeFactory._findSuperTypeChain(TypeFactory.java:958)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:285)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)
          com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732)
          com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303)
          com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279)
          com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891)

          We solved this error getting fields manually from the map _field, the code is:
          public List<Object> transformSolrDocumentsListToDocuments(SolrDocumentList searched) {
          List<Object> documents = new ArrayList<>();
          for (SolrDocument solrDocument : searched) {
          Map<String, Object> fields = new HashMap<>();
          for (String key : solrDocument.getFieldValueMap().keySet())

          { Object field = solrDocument.getFieldValue(key); fields.put(key, field); }

          documents.add(fields);
          }

          return documents;
          }

          Show
          jugaji Juan José added a comment - When upgrade Apache Solr from version 4.10 to 5.0.0, the parse serialization is not working from SolrDocument class to json. we use library com.fasterxml.jackson.core:jackson-databind:2.5.4 for json parsing. We are getting this exception: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1302) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871) javax.servlet.http.HttpServlet.service(HttpServlet.java:647) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) causa raíz java.lang.StackOverflowError com.fasterxml.jackson.databind.type.HierarchicType.getRawClass(HierarchicType.java:74) com.fasterxml.jackson.databind.type.TypeFactory._doFindSuperInterfaceChain(TypeFactory.java:1009) com.fasterxml.jackson.databind.type.TypeFactory._findSuperInterfaceChain(TypeFactory.java:1004) com.fasterxml.jackson.databind.type.TypeFactory._findSuperTypeChain(TypeFactory.java:958) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:285) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) com.fasterxml.jackson.databind.type.TypeFactory._fromClass(TypeFactory.java:732) com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:387) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:303) com.fasterxml.jackson.databind.type.TypeFactory.findTypeParameters(TypeFactory.java:279) com.fasterxml.jackson.databind.type.TypeFactory._mapType(TypeFactory.java:891) We solved this error getting fields manually from the map _field, the code is: public List<Object> transformSolrDocumentsListToDocuments(SolrDocumentList searched) { List<Object> documents = new ArrayList<>(); for (SolrDocument solrDocument : searched) { Map<String, Object> fields = new HashMap<>(); for (String key : solrDocument.getFieldValueMap().keySet()) { Object field = solrDocument.getFieldValue(key); fields.put(key, field); } documents.add(fields); } return documents; }
          Hide
          ichattopadhyaya Ishan Chattopadhyaya added a comment -

          This change was introduced in Solr 5.5 and should not affect 4.10 to 5.0 upgrade. Maybe the solr-users list might be better in terms of offering solutions for the problem you faced?

          Show
          ichattopadhyaya Ishan Chattopadhyaya added a comment - This change was introduced in Solr 5.5 and should not affect 4.10 to 5.0 upgrade. Maybe the solr-users list might be better in terms of offering solutions for the problem you faced?
          Hide
          jugaji Juan José added a comment -

          Sorry I made a mistake. It was to upgrade from 5.4.1 to 5.5.0.

          Show
          jugaji Juan José added a comment - Sorry I made a mistake. It was to upgrade from 5.4.1 to 5.5.0.
          Hide
          jugaji Juan José added a comment -

          This issue is controlled from version 2.7.3 of com.fasterxml.jackson.core:jackson-databind

          Show
          jugaji Juan José added a comment - This issue is controlled from version 2.7.3 of com.fasterxml.jackson.core:jackson-databind
          Hide
          elyograg Shawn Heisey added a comment -

          How does one actually convert SolrDocument to SolrInputDocument without the methods that no longer exist? This was discussed today in the #solr IRC channel, and the following SO post was mentioned: I tried a few ideas, but was unable to

          http://stackoverflow.com/questions/38266684/substitute-of-org-apache-solr-client-solrj-util-clientutils-tosolrinputdocument

          I've come up with an alternate plan to restoring the ClientUtils method – a constructor on SolrDocumentBase that accepts another SolrDocumentBase as an argument, and does a shallow copy.

          Show
          elyograg Shawn Heisey added a comment - How does one actually convert SolrDocument to SolrInputDocument without the methods that no longer exist? This was discussed today in the #solr IRC channel, and the following SO post was mentioned: I tried a few ideas, but was unable to http://stackoverflow.com/questions/38266684/substitute-of-org-apache-solr-client-solrj-util-clientutils-tosolrinputdocument I've come up with an alternate plan to restoring the ClientUtils method – a constructor on SolrDocumentBase that accepts another SolrDocumentBase as an argument, and does a shallow copy.

            People

            • Assignee:
              shalinmangar Shalin Shekhar Mangar
              Reporter:
              ichattopadhyaya Ishan Chattopadhyaya
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development