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
240
Knock! Knock! Who's There?
markush
0
64
An Introduction To Kubernetes ☸
markush
0
91
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
60
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
210
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
13k
Other Decks in Programming
See All in Programming
CSC305 Lecture 10
javiergs
PRO
0
220
Vueのバリデーション、結局どれを選べばいい? ― 自作バリデーションの限界と、脱却までの道のり ― / Which Vue Validation Library Should We Really Use? The Limits of Self-Made Validation and How I Finally Moved On
neginasu
2
180
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
880
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
850
SODA - FACT BOOK(JP)
sodainc
1
8.6k
iOSでSVG画像を扱う
kishikawakatsumi
0
150
Introduce Hono CLI
yusukebe
6
3k
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
2
360
Six and a half ridiculous things to do with Quarkus
hollycummins
0
210
AI Agent 時代的開發者生存指南
eddie
4
2.1k
Webサーバーサイド言語としてのRustについて
kouyuume
1
4k
Software Architecture
hschwentner
6
2.3k
Featured
See All Featured
The Invisible Side of Design
smashingmag
302
51k
Automating Front-end Workflow
addyosmani
1371
200k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Agile that works and the tools we love
rasmusluckow
331
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
Building an army of robots
kneath
306
46k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Music & Morning Musume
bryan
46
6.9k
Into the Great Unknown - MozCon
thekraken
40
2.1k
A designer walks into a library…
pauljervisheath
209
24k
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