@@ -124,8 +124,8 @@ def setUp(cls):
124124 cls .backend = MultiMatchSearchFilterBackend ()
125125 cls .view = BookMultiMatchSearchFilterBackendDocumentViewSet ()
126126
127- def _search_by_field (self , search_term , num_results , url = None ):
128- """Search by field ."""
127+ def _search (self , search_term , num_results , url = None ):
128+ """Search."""
129129 self .authenticate ()
130130
131131 if url is None :
@@ -194,9 +194,9 @@ def _search_boost(self, search_term, ordering, url=None):
194194 result_item = filtered_response .data ['results' ][counter ]
195195 self .assertEqual (result_item ['id' ], item_id )
196196
197- def test_search_by_field (self , url = None ):
198- """Search by field ."""
199- return self ._search_by_field (
197+ def test_search (self , url = None ):
198+ """Search."""
199+ return self ._search (
200200 search_term = 'Pool of Tears' ,
201201 num_results = 3 ,
202202 url = url
@@ -207,7 +207,7 @@ def test_search_boost(self, url=None):
207207
208208 :return:
209209 """
210- # Search for " The Pool of Tears"
210+ # Search for: The Pool of Tears
211211 self ._search_boost (
212212 search_term = "The Pool of Tears" ,
213213 ordering = [
@@ -218,7 +218,7 @@ def test_search_boost(self, url=None):
218218 url = url
219219 )
220220
221- # Search for " Pig and Pepper"
221+ # Search for: Pig and Pepper
222222 self ._search_boost (
223223 search_term = "Pig and Pepper" ,
224224 ordering = [
@@ -227,7 +227,7 @@ def test_search_boost(self, url=None):
227227 url = url
228228 )
229229
230- # Search for " and Pepper"
230+ # Search for: and Pepper"
231231 self ._search_boost (
232232 search_term = "and Pepper" ,
233233 ordering = [
@@ -238,7 +238,7 @@ def test_search_boost(self, url=None):
238238 url = url
239239 )
240240
241- # Search for " Who Stole the Tarts"
241+ # Search for: Who Stole the Tarts
242242 self ._search_boost (
243243 search_term = "Who Stole the Tarts" ,
244244 ordering = [
@@ -247,7 +247,7 @@ def test_search_boost(self, url=None):
247247 url = url
248248 )
249249
250- # Search for " Stole the Tarts"
250+ # Search for: Stole the Tarts
251251 self ._search_boost (
252252 search_term = "Stole the Tarts" ,
253253 ordering = [
@@ -257,7 +257,7 @@ def test_search_boost(self, url=None):
257257 url = url
258258 )
259259
260- # Search for " the Tarts"
260+ # Search for: the Tarts
261261 self ._search_boost (
262262 search_term = "the Tarts" ,
263263 ordering = [
@@ -268,6 +268,33 @@ def test_search_boost(self, url=None):
268268 url = url
269269 )
270270
271+ def test_search_selected_fields (self , url = None ):
272+ """Search boost.
273+
274+ :return:
275+ """
276+ # Search for (only in `title` and `summary`): and Pepper
277+ self ._search (
278+ search_term = 'title,summary:and Pepper' ,
279+ num_results = 2 ,
280+ url = url
281+ )
282+
283+ def test_search_boost_selected_fields (self , url = None ):
284+ """Search boost.
285+
286+ :return:
287+ """
288+ # Search for (only in `title` and `summary`): and Pepper
289+ self ._search_boost (
290+ search_term = 'title,summary:and Pepper' ,
291+ ordering = [
292+ self .non_lorem [3 ].pk ,
293+ self .non_lorem [4 ].pk ,
294+ ],
295+ url = url
296+ )
297+
271298 @unittest .skipIf (not CORE_API_AND_CORE_SCHEMA_ARE_INSTALLED ,
272299 CORE_API_AND_CORE_SCHEMA_MISSING_MSG )
273300 def test_schema_fields_with_filter_fields_list (self ):
0 commit comments