Skip to content

Instantly share code, notes, and snippets.

Avatar

Enrique Medina Montenegro emedina

View GitHub Profile
@emedina
emedina / groovyConsoleES_EM
Created Feb 8, 2011
Play around ES with Groovy console
View groovyConsoleES_EM
@GrabResolver(name='Codehaus', root='http://repository.codehaus.org')
@GrabResolver(name='Codehaus.Snapshots', root='http://snapshots.repository.codehaus.org')
@GrabResolver(name='Codehaus.Snapshots', root='http://oss.sonatype.org/content/repositories/releases/')
@GrabResolver(name='Codehaus.Snapshots', root='http://repo1.maven.org/maven2/')
@Grapes([
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1'),
@Grab(group='org.elasticsearch', module='elasticsearch-client-groovy', version='0.10.0'),
@Grab(group='org.elasticsearch', module='elasticsearch-lang-groovy', version='0.14.3'),
@Grab(group='org.apache.lucene', module='lucene-highlighter', version='3.0.3'),
@GrabExclude(group='xerces', module='xercesImpl')])
View testES1.em
{
"explain" : false,
"from" : 1,
"size" : 10,
"sort" : [ { "_score" : { } } ],
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : { "field" : { "_all" : "noche" } },
@emedina
emedina / ResultES
Created Feb 11, 2011
Result JSON for ES query
View ResultES
[{
"hits": {
"hits": [],
"max_score": 2.733024,
"total": 1
},
"timed_out": false,
"took": 20,
"_shards": {
"failed": 0,
@emedina
emedina / GroovyEventTraceConsoleOutput_EM.20110222
Created Feb 22, 2011
Output for Groovy Event Trace Console
View GroovyEventTraceConsoleOutput_EM.20110222
Code select : 19:50:35 Code select starting on ReunionService.groovy at [ 7586,0 ]
Code select : 19:50:35 Event complete: 0ms: Code select: ReunionService.groovy
Code select : 19:50:37 Code select starting on ReunionService.groovy at [ 6284,0 ]
Code select : 19:50:37 Event complete: 1ms: Code select: ReunionService.groovy
Code select : 19:50:49 Code select starting on ReunionService.groovy at [ 7802,0 ]
Code select : 19:50:49 Event complete: 1ms: Code select: ReunionService.groovy
Code select : 19:50:51 Code select starting on ReunionService.groovy at [ 7883,0 ]
Code select : 19:50:51 Event complete: 1ms: Code select: ReunionService.groovy
Code select : 19:50:53 Code select starting on ReunionService.groovy at [ 8090,0 ]
Code select : 19:50:53 Event complete: 1ms: Code select: ReunionService.groovy
@emedina
emedina / SpanishAnalyzer.java
Created Mar 16, 2011
Custom analyzer for Spanish
View SpanishAnalyzer.java
import java.io.Reader;
import java.util.Arrays;
import java.util.HashSet;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.ASCIIFoldingFilter;
import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.snowball.SnowballFilter;
@emedina
emedina / gist:913246
Created Apr 11, 2011
MVEL for script in custom_score_query
View gist:913246
{
"from": 0,
"size": 28,
"query": {
"custom_score": {
"query": {
"query_string": {
"query": "iphone"
}
},
View gist:944075
<script type="text/javascript" src="code.icepush"></script>
<script type="text/javascript">var notificationIds = [];</script>
View gist:944080
<script type="text/javascript">
if(!('2gmyrp6vy:12ge' in notificationIds)){
notificationIds.push('2gmyrp6vy:12ge');
ice.push.register(['2gmyrp6vy:12ge'], function(){
alert('HERE I AM');
});
}
</script>
View gist:944081
<script type="text/javascript">
//<![CDATA[
// Initialize a new counter
var myCounter;
var urlCounter = "/cuestamenos/counter";
jQuery.ajax({type:'POST', url:urlCounter,success:function(data,textStatus){ myCounter = new flipCounter('thecounter', {value: data, auto:false}); },error:function(XMLHttpRequest,textStatus,errorThrown){}});
//]]>
</script>
View gist:954972
{
"cluster_name" : "elasticsearch",
"nodes" : {
"Mq-PfDdMQw-KbmllLvvjnA" : {
"name" : "Death's-Head",
"indices" : {
"size" : "5.8gb",
"size_in_bytes" : 6245128521,
"docs" : {
"num_docs" : 5896306