@@ -350,3 +350,37 @@ def test_phrase_search(index_with_documents):
350350 assert 'release_date' in response ['hits' ][0 ]
351351 assert response ['hits' ][0 ]['title' ] == 'Dumbo'
352352 assert '_formatted' not in response ['hits' ][0 ]
353+
354+ def test_basic_search_on_nested_documents (index_with_documents , nested_movies ):
355+ """Tests search with an simple query on nested fields."""
356+ response = index_with_documents ('nested_fields_index' , nested_movies ).search ('An awesome' )
357+ assert isinstance (response , dict )
358+ assert response ['hits' ][0 ]['id' ] == 5
359+ assert len (response ['hits' ]) == 1
360+
361+ def test_search_on_nested_documents_with_searchable_attributes (index_with_documents , nested_movies ):
362+ """Tests search on nested fields with searchable attribute."""
363+ index = index_with_documents ('nested_fields_index' , nested_movies )
364+ response_searchable_attributes = index .update_searchable_attributes (['title' , 'info.comment' ])
365+ index .wait_for_task (response_searchable_attributes ['uid' ])
366+ response = index .search ('An awesome' )
367+ assert isinstance (response , dict )
368+ assert response ['hits' ][0 ]['id' ] == 5
369+ assert len (response ['hits' ]) == 1
370+
371+ def test_search_on_nested_documents_with_sortable_attributes (index_with_documents , nested_movies ):
372+ """Tests search on nested fields with searchable attribute and sortable attributes."""
373+ index = index_with_documents ('nested_fields_index' , nested_movies )
374+ response_settings = index .update_settings ({
375+ 'searchableAttributes' : ['title' , 'info.comment' ],
376+ 'sortableAttributes' : ['info.reviewNb' ],
377+ })
378+ index .wait_for_task (response_settings ['uid' ])
379+ response = index .search (
380+ '' ,
381+ {
382+ 'sort' : ['info.reviewNb:desc' ]
383+ }
384+ )
385+ assert isinstance (response , dict )
386+ assert response ['hits' ][0 ]['id' ] == 6
0 commit comments