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 / 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
text: This text will be used if nothing else is specified.
analyzer:
myAnalyzer:
type: custom
tokenizer: whitespace
filter:
- lowercase
- reverse
@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",
@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 / 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 / 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 / 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 / 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": {