Skip to content

Instantly share code, notes, and snippets.

View speedplane's full-sized avatar
🏛️
Analyzing court records.

Michael Sander speedplane

🏛️
Analyzing court records.
View GitHub Profile
@speedplane
speedplane / vax_finder
Last active March 30, 2021 05:03
New York Vaccine Alert Script
#!/bin/bash
#
# New York Vaccine Finder
#
# New York kindly provides a nice API to check for vaccine providers. But you need
# to constantly refresh their website. This script will check for you and will print
# out a message when it finds one.
#
# This script requires bash and jq to run.
# Find me at twitter.com/speedplane
@speedplane
speedplane / LargeTextFile
Created April 11, 2019 17:10
Large Text File
This file has been truncated, but you can view the full file.
18-23538-rdd Doc 1711 Filed 01/18/19 Entered 01/18/19 01:00:02 Main Document
Pg 1 of 1461
WEIL, GOTSHAL & MANGES LLP
767 Fifth Avenue
New York, New York 10153
Telephone: (212) 310-8000
Facsimile: (212) 310-8007
Ray C. Schrock, P.C.
Jacqueline Marcus
Garrett A. Fail
@speedplane
speedplane / celery_app.py
Created October 25, 2017 02:02
Celery Autoscaler Based on Memory and System Load
import multiprocessing
import re
from celery import Celery
from celery.worker.autoscale import Autoscaler as CeleryAutoscaler
class DAAutoscaler(CeleryAutoscaler):
# Try to keep the load above this point.
LOAD_MIN = .8
# Try to keep the load below this.
LOAD_MAX = 1.1

Extending Haystack's Elasticsearch backend

Haystack provides an interface similar to Django's QuerySet, which instead enables easy querying in one or more popular search backends. Because the Haystack SearchQuerySet API is meant to hook up to several search backends, however, not all the functionality of the backends has been implemented in the API. In this article we show how Haystack's Elasticsearch backend can be extended with advanced querying functionality.

As an exemplary use case, we'll focus on implementing Elasticsearch's Nested Query in the SearchQuerySetAPI, to enable e.g. weighted tags on documents. The usage of this extended API will be shown first, after which we'll go through the necessary implementation steps.

ConfigurableSearchQuerySet API Usage

import search.custom_elasticsearch as ces
from files import FileObject