forked from acdha/djangocon-internationalization-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
152 lines (127 loc) · 5.82 KB
/
search.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
<meta name="viewport" content="width=1024, user-scalable=no">
<title>Building International Sites: Searching Multilingual Content</title>
<!-- Required stylesheet -->
<link rel="stylesheet" href="deck.js/core/deck.core.css">
<link rel="stylesheet" href="deck.js/extensions/goto/deck.goto.css">
<link rel="stylesheet" href="deck.js/extensions/menu/deck.menu.css">
<link rel="stylesheet" href="deck.js/extensions/navigation/deck.navigation.css">
<link rel="stylesheet" href="deck.js/extensions/status/deck.status.css">
<link rel="stylesheet" href="deck.js/extensions/hash/deck.hash.css">
<link rel="stylesheet" href="deck.js/themes/style/swiss.css">
<link rel="stylesheet" href="custom.css">
<script src="deck.js/modernizr.custom.js"></script>
</head>
<body class="deck-container">
<section class="slide" id="intro">
<h1>Multilingual Search</h1>
</section>
<section class="slide">
<h2>Search Challenges</h2>
<ul>
<li>
Careful review is needed for result quality in multiple
languages
</li>
<li>
All Lucene-based engines, including Solr and ElasticSearch,
define language at the schema level, preventing you from
having a per-document setting for language. Your document can,
however, have <code>text_en</code>, <code>text_es</code>, etc.
defined and leave all but the appropriate one null.
</li>
<li>
Regular, preferably automated, testing is a good idea to
avoiding regressions, particularly if you're using any
language-specific customizations for stemming, synonyms,
etc.
</li>
</ul>
</section>
<section class="slide">
<h2>Searching with Solr</h2>
<p>
As with databases, we have to decide whether it's better to
store all of your content in a single Solr index with
language-specific fields or to use a separate cores for each
language. Because Solr likes to have a single document field
and to avoid needing to manage sets of per-language translated
field names in queries, I generally recommend the latter
approach, especially if your data is not synchronized across
languages.
</p>
<p>
The Solr example schema lists reasonable defaults for most
languages. You should plan to have a native speaker review your
results once you have realistic test data available.
</p>
</section>
<section class="slide">
<h2>Using django-haystack</h2>
<p class="note">
Haystack 1.x only supports a single Solr backend, which
requires some work to use multiple cores. When version 2.0 is
stable, this will mostly become a simple
<code>.using(lang)</code> call.
</p>
<ol>
<li>
search_sites.py: load multiple backends, one per language
</li>
<li>
search_indexes.py: configure get_queryset() to filter on
language when indexing
</li>
<li>
Change all views to retrieve the language-specific backend
rather than simply calling <code>SearchQuerySet()</code>
</li>
<li>
Create your own <code>update_index</code> and
<code>clear_index</code> management commands which use the
language-specific backends and filter database queries
accordingly
</li>
</ol>
</section>
<section class="slide exit">
<nav>
<a href="index.html#agenda">Back to agenda</a>
</nav>
</section>
<a href="#" class="deck-prev-link" title="Previous">←</a>
<a href="#" class="deck-next-link" title="Next">→</a>
<!-- deck.status snippet -->
<p class="deck-status">
<span class="deck-status-current"></span>
/
<span class="deck-status-total"></span>
</p>
<!-- deck.goto snippet -->
<form action="." method="get" class="goto-form">
<label for="goto-slide">Go to slide:</label>
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
<datalist id="goto-datalist"></datalist>
<input type="submit" value="Go">
</form>
<!-- deck.hash snippet -->
<a href="." title="Permalink to this slide" class="deck-permalink">#</a>
<script src="deck.js/jquery-1.7.2.min.js"></script>
<script src="deck.js/core/deck.core.js"></script>
<script src="deck.js/core/deck.core.js"></script>
<script src="deck.js/extensions/hash/deck.hash.js"></script>
<script src="deck.js/extensions/menu/deck.menu.js"></script>
<script src="deck.js/extensions/goto/deck.goto.js"></script>
<script src="deck.js/extensions/status/deck.status.js"></script>
<script src="deck.js/extensions/navigation/deck.navigation.js"></script>
<script>
$(function() {
$.deck('.slide');
});
</script>
</body>
</html>