Regards
I have been trying other things, like this:
> console
import net.liftweb.json._
import code.lib.ElasticSearch
val json = parse(""" { "query" : { "term" : { "name": "dos" }}} """)
implicit val formats = DefaultFormats
ElasticSearch.mongoindexSearch( json ) onSuccess {
response => println("\nReceived response: \n\n" +
parse( response.getContent.toString("UTF-8") ) + "\n")
}
and get the following:
Received response:
JObject(List(JField(took,JInt(6)), JField(timed_out,JBool(false)),
JField(_shards,JObject(List(JField(total,JInt(5)),
JField(successful,JInt(5)), JField(failed,JInt(0))))),
JField(hits,JObject(List(JField(total,JInt(1)),
JField(max_score,JDouble(1.9162908)),
JField(hits,JArray(List(JObject(List(JField(_index,JString(mongoindex)),
JField(_type,JString(posts)),
JField(_id,JString(508d53c73004fa29f951ceeb)),
JField(_score,JDouble(1.9162908)),
JField(_source,JObject(List(JField(_id,JString(508d53c73004fa29f951ceeb)),
JField(name,JString(dos)), JField(description,JString(dos)),
JField(userId,JString(50510321300407585a3d7e01)),
JField(timecreated,JInt(1351439303854)),
JField(published,JBool(true)))))))))))))))
and now, what I need is to extract the data
I'm trying this:
case class Posts(name: String, description: String )
ElasticSearch.mongoindexSearch( json ) onSuccess {
response => println("\nReceived response: \n\n" +
parse( response.getContent.toString("UTF-8") ).extract[Posts] + "\n")
}
but I get the following Exception:
GRAVE: Exception propagated to the root monitor!
net.liftweb.json.MappingException: No usable value for name
Did not find value which can be converted into java.lang.String
at net.liftweb.json.Meta$.fail(Meta.scala:191)
at net.liftweb.json.Extraction$.mkValue$1(Extraction.scala:
357)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:317)
at net.liftweb.json.Extraction$$anonfun
$12.apply(Extraction.scala:253)
at net.liftweb.json.Extraction$$anonfun
$12.apply(Extraction.scala:253)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:194)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:194)
at scala.collection.LinearSeqOptimized
$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike
$class.map(TraversableLike.scala:194)
at scala.collection.immutable.List.map(List.scala:45)
at net.liftweb.json.Extraction$.instantiate$1(Extraction.scala:
253)
at net.liftweb.json.Extraction$.newInstance$1(Extraction.scala:
286)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:315)
at net.liftweb.json.Extraction$.net$liftweb$json$Extraction$
$extract0(Extraction.scala:366)
at net.liftweb.json.Extraction$.net$liftweb$json$Extraction$
$extract0(Extraction.scala:199)
at net.liftweb.json.Extraction$.extract(Extraction.scala:43)
at net.liftweb.json.JsonAST$JValue.extract(JsonAST.scala:300)
at $line7.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:17)
at $line7.$read$$iw$$iw$$iw$$iw$$anonfun$1.apply(<console>:17)
at com.twitter.util.Future$$anonfun$onSuccess
$1.apply(Future.scala:514)
at com.twitter.util.Future$$anonfun$onSuccess
$1.apply(Future.scala:513)
at com.twitter.util.Promise$$anonfun$respond$2$$anonfun$apply
$1.apply$mcV$sp(Future.scala:853)
at com.twitter.util.Monitor$.apply(Monitor.scala:119)
at com.twitter.util.Promise$$anonfun$respond
$2.apply(Future.scala:853)
at com.twitter.util.Promise$$anonfun$respond
$2.apply(Future.scala:853)
at com.twitter.util.Promise$$anonfun$respondWithoutChaining
$1.apply(Future.scala:864)
at com.twitter.util.Promise$$anonfun$respondWithoutChaining
$1.apply(Future.scala:859)
at com.twitter.concurrent.IVar$$anonfun$runqs$1.apply$mcV
$sp(IVar.scala:174)
at com.twitter.concurrent.IVar$LocalScheduler.run(IVar.scala:
125)
at com.twitter.concurrent.IVar$LocalScheduler.apply(IVar.scala:
105)
at com.twitter.concurrent.IVar.runqs(IVar.scala:169)
at com.twitter.concurrent.IVar.set(IVar.scala:310)
at com.twitter.util.Promise.updateIfEmpty(Future.scala:834)
at com.twitter.util.Promise.update(Future.scala:821)
at com.twitter.util.Promise.setValue(Future.scala:804)
at com.twitter.concurrent.AsyncQueue.offer(AsyncQueue.scala:
66)
at
com.twitter.finagle.transport.ClientChannelTransport.handleUpstream(ChannelTransport.scala:
125)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at org.jboss.netty.channel.DefaultChannelPipeline
$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:
792)
at
org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:
100)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:
75)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at org.jboss.netty.channel.DefaultChannelPipeline
$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:
792)
at
org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:
111)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:
75)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at org.jboss.netty.channel.DefaultChannelPipeline
$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:
792)
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:
296)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:
567)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:
551)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:
445)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:
75)
at
org.jboss.netty.handler.codec.http.HttpClientCodec.handleUpstream(HttpClientCodec.java:
92)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at org.jboss.netty.channel.DefaultChannelPipeline
$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:
792)
at
org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:
149)
at
com.twitter.finagle.channel.ChannelStatsHandler.messageReceived(ChannelStatsHandler.scala:
77)
at
org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:
95)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at org.jboss.netty.channel.DefaultChannelPipeline
$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:
792)
at
org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:
149)
at
com.twitter.finagle.channel.ChannelRequestStatsHandler.messageReceived(ChannelRequestStatsHandler.scala:
35)
at
org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:
95)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
564)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:
559)
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:
268)
at
org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:
255)
at
org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:94)
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:
364)
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:
238)
at
org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
at org.jboss.netty.util.internal.DeadLockProofWorker
$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: net.liftweb.json.MappingException: Did not find value which
can be converted into java.lang.String
at net.liftweb.json.Meta$.fail(Meta.scala:191)
at net.liftweb.json.Extraction$.convert(Extraction.scala:403)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:314)
at net.liftweb.json.Extraction$.mkValue$1(Extraction.scala:
351)
... 74 more
how I can fix this?
anyone has any suggestions please
Thanks for your attention