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
160
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
200
Knock! Knock! Who's There?
markush
0
61
An Introduction To Kubernetes ☸
markush
0
80
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
13k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
51
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
190
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
13k
Other Decks in Programming
See All in Programming
Boos Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
390
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
320
React 19アップデートのために必要なこと
uhyo
8
1.5k
複数のAWSアカウントから横断で 利用する Lambda Authorizer の作り方
tc3jp
0
120
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
270
ABEMA iOS 大規模プロジェクトにおける段階的な技術刷新 / ABEMA iOS Technology Upgrade
akkyie
1
200
CloudNativePGを布教したい
nnaka2992
0
110
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.6k
Learning Kotlin with detekt
inouehi
1
140
From the Wild into the Clouds - Laravel Meetup Talk
neverything
0
160
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
0
200
Featured
See All Featured
Building an army of robots
kneath
303
45k
Site-Speed That Sticks
csswizardry
4
410
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
RailsConf 2023
tenderlove
29
1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
430
A designer walks into a library…
pauljervisheath
205
24k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
Faster Mobile Websites
deanohume
306
31k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
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