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

ManagedResource PUT and POST should behave differently

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.10.3
    • Fix Version/s: None
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      We are testing the new ManagedResource for managing our Synonym filter and although it works pretty well we find it quite difficult to manage the list using the API. Specially there is no difference in using POST and PUT verbs and IMHO they should behave slightly different. Let me explain.

      We start with an empty synonyms list, and we push the first synonym

      curl -X PUT -H 'Content-type:application/json' --data-binary '{"mad":["angry","upset", "error"]}' "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english"
      

      Everyting works ok! Now I realise I made a mistake and one of the synonyms is incorrect. My instinct says that if i PUT the correct list again it will be overwritten.

      curl -X PUT -H 'Content-type:application/json' --data-binary '{"mad":["angry","upset"]}' "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english"
      

      But here nothing happens, the list stays the same wit the "error" synonym still in it. I have to DELETE thelist for the "mad" key and PUT it again.

      curl -X DELETE  "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english/mad"
      curl -X PUT -H 'Content-type:application/json' --data-binary '{"mad":["angry","upset"]}' "http://localhost:8983/solr/techproducts/schema/analysis/synonyms/english"
      

      My proposal is that a PUT command should replace the list entirely, no matter what was in the list (which in turn should be more performant, as it would not need to iterate the whole list looking for additions to be made). A POST command should work like it is working now, where only the additions are processed.

      That would also enable to submit a whole list using PUT. Right now if you want to replace all the synonyms you have to delete them one by one and then POST/PUT the entire list. With this modification you would PUT the whole list and it would be replaced.

      I am not quite familiar with the Solr java code but I guess I should be able to submit a patch If the issue is considered.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              acasademont Albert Casademont
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: