Skip to content

Instantly share code, notes, and snippets.

View babadofar's full-sized avatar
💭
Infinity

Christoffer Vig babadofar

💭
Infinity
View GitHub Profile
@babadofar
babadofar / demo1
Last active August 29, 2015 13:59
Elasticsearch search template demo
curl -XGET "http://localhost:9200/seasonalfoods/_search/template" -d'
{
"template": {
"query": {
"match": {
"ingredients": "{{ingredientsParam}}"
}
}
},
"params": {
@babadofar
babadofar / gist:11193668
Created April 22, 2014 20:45
Windows System Email
param ([Parameter(Mandatory=$true)][string]$query)
$con = New-Object -TypeName System.Data.OleDb.OleDbConnection
$con.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
$con.Open()
$cmd = $con.CreateCommand()
$query = "SELECT Top 5 System.ItemPathDisplay FROM SYSTEMINDEX WHERE contains(*, '$($query)*') AND System.Kind = 'email'"
$cmd.CommandText = $query
$rdr = $cmd.ExecuteReader()
while ($rdr.Read()) {
@babadofar
babadofar / elasticsearch ngram tokenizer
Last active August 29, 2015 14:02
Compound words demo with ngram tokenizer elasticsearch
#!/bin/bash
export ELASTICSEARCH_ENDPOINT="http://localhost:9200"
# Create indexes
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{
"settings": {
"analysis": {
"analyzer": {
@babadofar
babadofar / analysis.yaml
Created June 25, 2014 21:48
Testing search in nested documents
text: This text will be used if nothing else is specified.
analyzer:
myAnalyzer:
type: custom
tokenizer: whitespace
filter:
- lowercase
- reverse
@babadofar
babadofar / Checking out the list of ingredients
Last active August 29, 2015 14:03
Elasticsearch function_score for recipe app. Updated with using groovy as scripting language, Elasticsearch version 1.3.0
curl -XPOST "http://localhost:9200/seasonalfoods/_search" -d'
{
"size": 0,
"aggs": {
"ingredients": {
"filter": { "terms": {
"ingredients": [
"jordbær",
"rips",
@babadofar
babadofar / terms
Last active August 29, 2015 14:03
Elasticsearch function_score demo
curl -XPOST "http://localhost:9200/seasonalfoods/_search" -d'
{ "explain":true,
"query": {
"terms": {
"ingredients": [
"jordbær",
"bringebær",
"rips",
"solbær",
"stikkelsbær",
text: This text will be used if nothing else is specified.
analyzer:
myAnalyzer:
type: custom
tokenizer: whitespace
filter:
- lowercase
- reverse
@babadofar
babadofar / vinmonopolet.sql
Created February 4, 2015 11:49
Vinmonopolet csv dump postgres import
-- data http://www.vinmonopolet.no/api/produkter
-- beskrivelse http://vertical.vinmonopolet.no/vmp/om-vinmonopolet/datadeling/_attachment/434521?_ts=1468fb68128
-- prepare the downloaded data by replacing Norwegian numeric separator , with . (using this regex:(\d),(\d) replace:\1.\2
-- In my csv file there was a lonely double quote, that had to be manually deleted
--DROP DATABASE "vinmonopolet";
CREATE DATABASE "vinmonopolet";
\connect vinmonopolet postgres
@babadofar
babadofar / produkter20150202-002145-032.csv
Created February 4, 2015 12:05
Vinmonopolet produkter csv 20150202
We can't make this file beautiful and searchable because it's too large.
Datotid;Varenummer;Varenavn;Volum;Pris;Literpris;Varetype;Produktutvalg;Butikkategori;Fylde;Friskhet;Garvestoffer;Bitterhet;Sodme;Farge;Lukt;Smak;Passertil01;Passertil02;Passertil03;Land;Distrikt;Underdistrikt;Argang;Rastoff;Metode;Alkohol;Sukker;Syre;Lagringsgrad;Produsent;Grossist;Distributor;Emballasjetype;Korktype;Vareurl
2015-02-02T00:21:16;1101;L�iten Linie;0.70;399.90;571.30;Akevitt;Basisutvalget;Butikkategori 3;0;0;0;0;0;;;;;;;Norge;�vrige;�vrige;;Poteter, krydder;16 mnd p� fat;41.50;5.00;Ukjent;;;Arcus AS;Vectura AS;Engangsflasker av glass;;http://www.vinmonopolet.no/vareutvalg/varedetaljer/sku-1101
;1102;L�iten Linie;0.35;239.90;685.40;Akevitt;Basisutvalget;Butikkategori 3;0;0;0;0;0;;;;;;;Norge;�vrige;�vrige;;Poteter, krydder;Lagret 16 md. p� fat.;41.50;5.00;Ukjent;;;Arcus AS;Vectura AS;Engangsflasker av glass;;http://www.vinmonopolet.no/vareutvalg/varedetaljer/sku-1102
;1201;Gilde Non Plus Ultra;0.70;599.90;857.00;Akevitt;Bestillingsutvalget;Uavhengig sortiment;0;0;0;0;0;Middels dyp gyllengul.;Arom
@babadofar
babadofar / installfeeder.ps1
Created February 4, 2015 12:57
jdbc-river install feeder powershell script
function Get-PSVersion {
if (test-path variable:psversiontable) {$psversiontable.psversion} else {[version]"1.0.0.0"}
}
$powershell = Get-PSVersion
if($powershell.Major -le 2 ){
Write-Error "Oh, so sorry, this script requires Powershell 3 (due to convertto-json)"
exit
}