Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Integrating Sphinx and Elasticsearch
Markus H
February 12, 2015
Programming
0
140
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
98
Knock! Knock! Who's There?
markush
0
42
An Introduction To Kubernetes ☸
markush
0
61
Writing Safe Database Migrations (DjangoCon Europe 2021)
markush
0
11k
A Pony On The Move: How Migrations Work In Django 🐎
markush
0
11k
All Hands on Deck — Handling Security Issues
markush
0
11k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
35
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
150
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
11k
Other Decks in Programming
See All in Programming
xarray-Datatree: Hierarchical Data Structures for Multi-Model Science
tomnicholas
0
230
Makuakeの認証基盤とRe-Architectureチーム
bmf_san
0
630
Hatena Engineer Seminar #23「新卒研修で気軽に『ありがとう』を伝え合える Slack アプリを開発した話」
slashnephy
0
380
LIFFで動く割り勘アプリTATEKAをリリースしてみた話
inoue2002
0
260
Qiita Night PHP 2023
fuwasegu
0
11k
Excelの助けを借りて楽にシナリオを作ろう
rpa_niiyama
0
330
Showkase、Paparazziを用いたビジュアルリグレッションテストの導入にチャレンジした話 / MoT TechTalk #15
mot_techtalk
0
120
Zynq MP SoC で楽しむエッジコンピューティング ~RTLプログラミングのススメ~
ryuz88
0
390
TokyoR#103_DataProcessing
kilometer
0
540
エンジニア向け会社紹介資料/engineer-recruiting-pitch
xmile
PRO
0
110
Enumを自動で網羅的にテストしてみた
estie
0
1.3k
OSSから学んだPR Descriptionの書き方
fugakkbn
4
140
Featured
See All Featured
BBQ
matthewcrist
75
8.1k
Ruby is Unlike a Banana
tanoku
93
9.6k
KATA
mclloyd
12
9.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
317
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1.1M
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
840
Debugging Ruby Performance
tmm1
67
11k
Principles of Awesome APIs and How to Build Them.
keavy
117
15k
Git: the NoSQL Database
bkeepers
PRO
419
60k
Done Done
chrislema
178
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
217
21k
Fantastic passwords and where to find them - at NoRuKo
philnash
32
1.9k
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