Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
fmpwizard / form.html
Created September 8, 2011 08:16
Validation as you type in Lift
<div>
<form class="lift:InventoryCreate?form=post;multipart=true">
<fieldset>
<legend><span>Main Information</span></legend>
<ol>
<li><label for="part_number">Part Number</label>
<input id="part_number" name="part_number" class="text" type="text" /><br>
<p id="part_number_error" class=""></p>
</li>
<li><label for="description">Description:</label>
lazy val cometClass= "MyCometClass"
lazy val name= net.liftweb.util.Helpers.nextFuncName
<div class="lift:PutCometOnPage">
</div>
CometListerner.listenerFor(Full(item)) match {
case a: LiftActor => info(bid); a ! Message(item, (bid.toDouble + 1.00))
case _ => info("No actor to send an update")
}
@fmpwizard
fmpwizard / gist:1349360
Created November 8, 2011 21:47
facet across multiple types
curl -X DELETE "http://localhost:9200/articles"
curl -X POST "http://localhost:9200/articles/article/1" -d '
{
"title" : "One"
}'
curl -X POST "http://localhost:9200/articles/article/2" -d '
{
"title" : "Two"
}'
@fmpwizard
fmpwizard / actual_result.sh
Created November 9, 2011 05:26
Actual result
curl -X POST "http://localhost:9200/articles/_search?pretty=true" -d '
{
"query" : { "query_string" : {"query" : "T*"} },
"facets" : {
"tags" : { "terms" : {"field" : "tags"} }
}
}
'
{
"took" : 5,
curl -X POST "http://localhost:9200/articles/_search?pretty=true" -d '
{
"query" : { "query_string" : {"query" : "T*"} },
"filter" : { "type": { "value": "article" }} ,
"facets" : {
"tags" : { "terms" : {"field" : "tags"} }
}
}
'
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 2,
"other" : 0,
"terms" : [ {
"term" : "foo",
"count" : 2
} ]
scala>
scala> import net.liftweb.json._
import net.liftweb.json._
scala>
scala> implicit val formats = DefaultFormats
formats: net.liftweb.json.DefaultFormats.type = net.liftweb.json.DefaultFormats$@33462704
class InventorySearch extends Logger with myScalaz.Boxes {
def results = {
val searchBoxText= S.param("p")
val doSearch= new DoSearch
lazy val searchResult= doSearch.queryElasticSearch(searchBoxText) // Returns Elastic Search results in json format
lazy val invItems=
searchResult map { x =>