Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Integrating Sphinx and Elasticsearch
Search
Markus H
February 12, 2015
Programming
0
170
Integrating Sphinx and Elasticsearch
This is a lightning talk presentation I gave a the Python Users Berlin meetup on Feb 12, 2015
Markus H
February 12, 2015
Tweet
Share
More Decks by Markus H
See All by Markus H
🐍 ❤️ 🦀 — Python loves Rust
markush
0
230
Knock! Knock! Who's There?
markush
0
64
An Introduction To Kubernetes ☸
markush
0
90
Writing Safe Database Migrations (DjangoCon Europe 2021)
markush
0
14k
A Pony On The Move: How Migrations Work In Django 🐎
markush
0
13k
All Hands on Deck — Handling Security Issues
markush
0
14k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
58
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
200
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
13k
Other Decks in Programming
See All in Programming
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
140
testingを眺める
matumoto
1
140
Kiroで始めるAI-DLC
kaonash
2
630
ファインディ株式会社におけるMCP活用とサービス開発
starfish719
0
2k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
310
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
540
Testing Trophyは叫ばない
toms74209200
0
890
AWS発のAIエディタKiroを使ってみた
iriikeita
1
190
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
120
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
510
「待たせ上手」なスケルトンスクリーン、 そのUXの裏側
teamlab
PRO
0
570
1から理解するWeb Push
dora1998
7
1.9k
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Art of Programming - Codeland 2020
erikaheidi
56
13k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
580
A Modern Web Designer's Workflow
chriscoyier
696
190k
We Have a Design System, Now What?
morganepeng
53
7.8k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Scaling GitHub
holman
463
140k
4 Signs Your Business is Dying
shpigford
184
22k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Code Review Best Practice
trishagee
71
19k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Transcript
Sphinx and Elasticsearch
• elasticsearch-dsl==0.0.3 • Sphinx==1.2.3 Which libraries to use?
def setup(app): app.connect( 'doctree-resolved', index ) Sphinx integration
from elasticsearch_dsl import DocType, String class Document(DocType): title = String(analyzer='snowball',
boost=5) body = String(analyzer='snowball') docname = String(index='not_analyzed') class Meta: index = 'docs' Elasticsearch Document
import hashlib from elasticsearch_dsl.connections import connections connections.create_connection(hosts=['localhost']) def index(app, doctree,
docname): title = app.env.titles[docname].astext() doc = Document( title=title, body=doctree.astext(), docname=docname, ) doc.id = hashlib.md5(docname.encode('utf-8')).hexdigest() doc.save() Index a Document
from elasticsearch_dsl.connections import connections connections.create_connection(hosts=['localhost']) search = Document.search() query =
search.query( 'query_string', query='Migrations', fields=['title', 'body'], ).highlight_options(order='score').highlight('body') results = query.execute() Search
>>> for hit in results: ... print(hit.title) Writing database migrations
Writing your first Django app, part 1 Django documentation FAQ: Databases and models System check framework ... Using the hits
Thank you! markusholtermann.eu @m_holtermann github.com/MarkusH