Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@peterdm
peterdm / gist:e1ebf6e17505e73ab10834d2458d60c9
Last active August 2, 2022 19:07
Mapping changes which require changes to index settings (applied to existing index)
# Original Index Structure (just took the pages field for brevity)
PUT test_index
{
"settings": {
"analysis": {
"char_filter": {
"punct_annotation": {
"type": "mapping",

Keybase proof

I hereby claim:

  • I am peterdm on github.
  • I am peterdm (https://keybase.io/peterdm) on keybase.
  • I have a public key ASAFL7lga1BSZAoVc131FLSB9EeoSISn3zdpO13W61CGBQo

To claim this, I am signing this object:

@peterdm
peterdm / rank_metrics.py
Created March 29, 2016 18:47 — forked from bwhite/rank_metrics.py
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@peterdm
peterdm / gist:9e31be343a733c44ff0e
Last active February 5, 2023 17:05
Elasticsearch semi-equivalent of Solr "bf=product(query('cat'),query('dog'))"
GET /my_index/my_type/_search
{
"query": {
"function_score": {
"query": { <ORIGINAL QUERY> },
"functions": [
{
"filter" : {
"term" : { "_all" : "cat"}
},
filter.strategy : { /* strategy is just what I named content_type … I’ll probably rename it */
type: single, /* or multiple - how many selections are allowed */
suggest: false, /* how many options can be selected */
count: 5, /*
order: top, /* top options, or alpha */
subfilters: {
recipe : { /* which parent selection would trigger these sub filters */
filter.recipe.course : { … },
filter.recipe.dish : { … },
@peterdm
peterdm / notifier.php
Created March 16, 2012 16:53
Implementing Observer pattern in PHP for an unkempt social network -- refactored hundreds of inconsistant ad-hoc calls into a handful of concrete classes bound declaratively via a config file. Net effect: Consistency and easy centralized maintenance.
<?php
uses_model('top/user_object');
uses_model('message/message');
uses_model('notifications/notification_queue');
uses_model('notifications/subscription');
/**
* Notifier is one of several Observers. Each Observer takes action across a particular channel.
* Notifier queues messages for delivery to users' mailboxes within the social network.
*
@peterdm
peterdm / dotcloud_build.yml
Created January 3, 2012 16:37 — forked from wheresalice/dotcloud_build.yml
Tech demo of Faye/NodeJS/Jade pubsub
www:
requirements:
- faye
- jade