multiple same-named parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple same-named parameters

Erik Hatcher
In my application I'm POSTing into the Solr for querying, and need to  
specify any number of "constraints" (which correspond to BitSet  
filters that get combined into a BitDocSet as a filter on the  
query).  Rather than have the client uniquely name each of the  
parameters, I want to name them all "constraint" in the request.  The  
servlet API supports this, but SolrQueryRequest currently does not.  
I've patched my local copy with the following and it all works fine.  
For LocalSolrQueryRequest, since it is using a Map for the arguments  
anyway, I simply added the new getParams method to return a single  
item array.

Any objections to me committing this?

Thanks,
        Erik



Index: src/java/org/apache/solr/request/LocalSolrQueryRequest.java
===================================================================
--- src/java/org/apache/solr/request/LocalSolrQueryRequest.java  
(revision 395947)
+++ src/java/org/apache/solr/request/LocalSolrQueryRequest.java  
(working copy)
@@ -70,6 +70,10 @@
      return (String)args.get(name);
    }
+  public String[] getParams(String name) {
+    return new String[] {(String)args.get(name)};
+  }
+
    public String getQueryString() {
      return query;
    }
Index: src/java/org/apache/solr/request/SolrQueryRequest.java
===================================================================
--- src/java/org/apache/solr/request/SolrQueryRequest.java      
(revision 395947)
+++ src/java/org/apache/solr/request/SolrQueryRequest.java      
(working copy)
@@ -31,6 +31,8 @@
    public String getParam(String name);
+  public String[] getParams(String name);
+
    public String getQueryString();
    // signifies the syntax and the handler that should be used
Index: src/webapp/src/org/apache/solr/servlet/SolrServletRequest.java
===================================================================
--- src/webapp/src/org/apache/solr/servlet/
SolrServletRequest.java      (revision 395947)
+++ src/webapp/src/org/apache/solr/servlet/
SolrServletRequest.java      (working copy)
@@ -25,7 +25,11 @@
      return req.getParameter(name);
    }
+  public String[] getParams(String name) {
+    return req.getParameterValues(name);
+  }
+
    public String getParamString() {
      StringBuilder sb = new StringBuilder(128);
      try {

Reply | Threaded
Open this post in threaded view
|

Re: multiple same-named parameters

Chris Hostetter-3

: For LocalSolrQueryRequest, since it is using a Map for the arguments
: anyway, I simply added the new getParams method to return a single
: item array.

I would suggest that LocalSolrRequest be modified a little more so that if
the value of an entry in the Map is an Array, then getParams returns the
Array, and getParam returns the first item in the array.




-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: multiple same-named parameters

Erik Hatcher

On Apr 21, 2006, at 1:53 PM, Chris Hostetter wrote:

>
> : For LocalSolrQueryRequest, since it is using a Map for the arguments
> : anyway, I simply added the new getParams method to return a single
> : item array.
>
> I would suggest that LocalSolrRequest be modified a little more so  
> that if
> the value of an entry in the Map is an Array, then getParams  
> returns the
> Array, and getParam returns the first item in the array.

Done and committed.

        Erik