post multiple key/value pairs with the key having the same value

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

post multiple key/value pairs with the key having the same value

getagrip
This post was updated on .
Hi,

how would I add multiple key/value pairs to the dispatch-request with the key having the same value?
I need to pass values as multivalued fields to an Apache Solr Server like so:

userid -> joe
userid -> sally

Unfortunately using a MultiMap does not work:

val user_ids = new HashMap[String, Set[String]] with MultiMap[String, String]

users foreach ( user => user_ids.addBinding("userid", user.id) )

request << user_ids

http(request / uri)


Reply | Threaded
Open this post in threaded view
|

Re: pass multimap to request

n8han
Administrator
Your only option currently is to write your own client code to replace what << is doing, because that method uses a class (SimplePost) that incorrectly models the post body as a Map.

You need something along the lines of this:

myRequest.next {
  val p = new org.apache.http.client.methods.HttpPost
  p.setEntity(new org.apache.http.client.entity.UrlEncodedFormEntity(...))
  Request.mimic(p)_
}

This is going to work completely differently in 0.8 so that it won't be an issue, but I can't say when there will be a final release of that.

Nathan

On 01/04/2011 02:02 PM, getagrip [via Databinder] wrote:
Hi,

how would I pass data with multiple-redundant keys to the Request object?
I need to pass values as multivalued fields to an Apache Solr Server.

Unfortunately using a MultiMap does not work:

val user_ids = new HashMap[String, Set[String]] with MultiMap[String, String]

users foreach ( user => user_ids.addBinding("userid", user.id) )

request << user_ids

http(request / uri)





View message @ http://databinder.3617998.n2.nabble.com/pass-multimap-to-request-tp5889785p5889785.html
To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.