Hi Hoss, Thanks for the pointers, and sorry, it was a bug in my code (was some dead code which was alphabetizing the facet link text and also the parameters themselves indirectly by reference).
I actually ended up building a servlet and a component to print out the multi-valued parameters using HttpServletRequest.getParameterValues("myparam") and ResponseBuilder.req.getParams().getParams("myparam") respectively to isolate the problem. Both of them returned the parameters in the correct order. So I went trolling through the code with a debugger, to observe exactly at what point the order got messed up, and found the bug. FWIW, I am using Tomcat 5.5. Thanks to everybody for their help, and sorry for the noise, guess I should have done the debugger thing before I threw up my hands :-). -sujit On Mar 19, 2012, at 6:55 PM, Chris Hostetter wrote: > > : I have a custom component which depends on the ordering of a > : multi-valued parameter. Unfortunately it looks like the values do not > : come back in the same order as they were put in the URL. Here is some > : code to explain the behavior: > ... > : and I notice that the values are ordered differently than ["foo", "bar", > : "baz"] that I would have expected. I am guessing its because the > : SolrParams is a MultiMap structure, so order is destroyed on its way in. > > a) MultiMapSolrParams does not destroy order on the way in > b) when dealing with HTTP requests, the request params actaully use an > instance of ServletSolrParams which is backed directly by the > ServletRequest.getParameterMap() -- you should get the values returned in > the exact order as ServletRequest.getParameterMap().get("myparam") > > : 1) is there a setting in Solr can use to enforce ordering of > : multi-valued parameters? I suppose I could use a single parameter with > : comma-separated values, but its a bit late to do that now... > > Should already be enforced in MultiMapSolrParams and ServletSolrParams > > : 2) is it possible to use a specific SolrParams object that preserves order? > If so how? > > see above. > > : 3) is it possible to get a reference to the HTTP request object from within > a component? If so how? > > not out of the box, because there is no garuntee that solr is even running > in a servlet container. you can subclass SolrDispatchFilter to do this if > you wish (note the comment in the execute() method). > > My questions to you... > > 1) what servlet container are you using? > 2) have you tested your servlet > container with a simple servlet (ie: eliminate solr from the equation) to > verify that the ServletRequest.getParameterMap() contains your request > values in order? > > > if you debug this and find evidence that something in solr is re-ordering > the values in a MultiMapSolrParams or ServletSolrParams *PLEASE* open a > jira with a reproducable example .. that would definitley be an anoying > bug we should get to the bottom of. > > > -Hoss