Skip to content

Commit b289a62

Browse files
Add fuzzy to docs
1 parent 87dc7d2 commit b289a62

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

docs/search_backends.rst

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ Compound search filter backend
66
==============================
77
Compound search filter backend aims to replace old style `SearchFilterBackend`.
88

9-
Sample view
9+
Multi-match
1010
-----------
11+
Sample view
12+
~~~~~~~~~~~
1113

1214
.. code-block:: python
1315
@@ -44,14 +46,14 @@ Sample view
4446
ordering = ('_score', 'id', 'title', 'price',)
4547
4648
Sample request
47-
--------------
49+
~~~~~~~~~~~~~~
4850

4951
.. code-block:: text
5052
5153
http://localhost:8000/search/books-compound-search-backend/?search=enim
5254
5355
Generated query
54-
---------------
56+
~~~~~~~~~~~~~~~
5557

5658
.. code-block:: javascript
5759
@@ -92,6 +94,74 @@ Generated query
9294
}
9395
}
9496
97+
Fuzzy search
98+
------------
99+
100+
Sample view
101+
~~~~~~~~~~~
102+
103+
.. code-block:: python
104+
105+
class BookCompoundFuzzySearchBackendDocumentViewSet(DocumentViewSet):
106+
# ...
107+
filter_backends = [
108+
# ...
109+
CompoundSearchFilterBackend,
110+
# ...
111+
]
112+
113+
search_fields = {
114+
'title': {'fuzziness': 'AUTO'},
115+
'description': None,
116+
'summary': None,
117+
}
118+
119+
120+
Sample request
121+
~~~~~~~~~~~~~~
122+
123+
.. code-block:: text
124+
125+
http://localhost:8000/search/books-compound-fuzzy-search-backend/?search=Performance
126+
127+
Generated query
128+
~~~~~~~~~~~~~~~
129+
130+
.. code-block:: javascript
131+
132+
{
133+
"from": 0,
134+
"size": 1,
135+
"query": {
136+
"bool": {
137+
"should": [
138+
{
139+
"match": {
140+
"title": {
141+
"fuzziness": "AUTO",
142+
"query": "Performance"
143+
}
144+
}
145+
},
146+
{
147+
"match": {
148+
"description": {
149+
"query": "Performance"
150+
}
151+
}
152+
},
153+
{
154+
"match": {
155+
"summary": {
156+
"query": "Performance"
157+
}
158+
}
159+
}
160+
]
161+
}
162+
}
163+
}
164+
95165
Multi match search filter backend
96166
=================================
97167
Document and serializer definition are trivial (there are lots of examples

0 commit comments

Comments
 (0)