This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RM: Imports | |
import scala.collection._ | |
import org.apache.lucene.util._ | |
import org.apache.lucene.analysis.es._ | |
import org.apache.lucene.analysis.standard._ | |
import org.apache.lucene.analysis.snowball._ | |
// RM: Where analyzer is | |
val TextAnalyzer = new StandardAnalyzer(Version.LUCENE_35, SpanishAnalyzer.getDefaultStopSet) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Views.Index = Backbone.View.extend({ | |
tagName: "input", | |
className: "search-query", | |
initialize: function() { | |
this.items = this.options.items; | |
this.key = this.options.key; | |
this.autocomplete = $('.search-query').typeahead(); | |
this.autocomplete.source = []; | |
this.autocomplete.on('keyup', this, this.typeaheadLookup); | |
if ( this.key != null ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// application.js | |
var App = { | |
Views: {}, | |
Controllers: {}, | |
Collections: {}, | |
init: function() { | |
new App.Controllers.TypeaheadItems(); | |
Backbone.history.start(); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"item":"VARELA INC."},{"item":"VARELA HERMANOS, S.A."},{"item":"VARELA OIL COMPANY (VAROCO)"},{"item":"VARELA Y MOLLEK S.A."},{"item":"VARELA REAL ESTATES S.A."},{"item":"VARELA CHEMICAL COMPANY INC."},{"item":"VARELA CONSULTING, S.A."},{"item":"VARELA-BARSALLO, S.A."},{"item":"COHEN, VASSILIPULOS, VARELA & CO.,"},{"item":"VARELA INTERNACIONAL,SA."}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RM: https://github.com/molekilla/ScalaRegPubRobot/blob/master/src/com/ecyware/web/robot/RegPubStorage.scala | |
def saveOrUpdate(items:Map[String,Object]) { | |
// webdata is database | |
// regpub is collection | |
val ficha = if ( items.containsKey("ficha") ) Some(items("ficha").toString) else None | |
if ( ficha.isDefined ) { | |
val document = items.asDBObject | |
val existingItems = mongoCollection.find(document) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import com.mongodb.casbah.Imports._ | |
import com.mongodb.casbah.commons.conversions.scala._ | |
import com.mongodb._ | |
import com.mongodb.ServerAddress | |
import com.mongodb.util._ | |
import scalaj.collection.s2j._ | |
abstract trait RegpubDataUtil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RegPubServices | |
class RegPubServices extends SearchService with DataModelService { | |
def searchTypeahead(query:String):JsValue = { | |
val hits = typeahead(query) | |
val companyNames = hits.map( hit => (hit \\ "fields").map( h => Map("item" -> h \ "nombre"))).flatten | |
// RM: Alternativamente, para no usar Underscore para crear un array | |
// val companyNames = hits.map( hit => (hit \\ "fields").map( h => h \ "nombre")).flatten | |
Json.toJson(companyNames) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import play.api.libs.json._ | |
import org.elasticsearch.action.index._ | |
import org.elasticsearch.common.settings._ | |
import org.elasticsearch.client.transport._ | |
import org.elasticsearch.common.transport.InetSocketTransportAddress | |
import org.elasticsearch.action.search._ | |
import org.elasticsearch.index.query._ | |
import org.elasticsearch.search.sort._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import play.api.libs.json._ | |
import play.api.Logger._ | |
object RegPubServices | |
{ | |
def apply() = new RegPubServices() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import play.api.libs.json._ | |
import org.elasticsearch.action.index._ | |
import org.elasticsearch.common.settings._ | |
import org.elasticsearch.client.transport._ | |
import org.elasticsearch.common.transport.InetSocketTransportAddress | |
import org.elasticsearch.action.search._ | |
import org.elasticsearch.index.query._ | |
import org.elasticsearch.search.sort._ |