File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -596,6 +596,32 @@ def test_index_writer_context_block(self, schema):
596
596
result = index .searcher ().search (Query .all_query ())
597
597
assert len (result .hits ) == 1
598
598
599
+ def test_simple_search_facet (self ):
600
+ schema = (
601
+ tantivy .SchemaBuilder ()
602
+ .add_text_field ("title" , stored = True )
603
+ .add_facet_field ("category" )
604
+ )
605
+ index = Index (schema .build ())
606
+ writer = index .writer (15_000_000 , 1 )
607
+ doc = Document ()
608
+ doc .add_text ("title" , "Book about whales" )
609
+ doc .add_facet (
610
+ "category" ,
611
+ tantivy .Facet .from_string ("/books/fiction" )
612
+ )
613
+ with writer :
614
+ writer .add_document (doc )
615
+
616
+ index .reload ()
617
+
618
+ query = index .parse_query ("+category:/books" )
619
+ result = index .searcher ().search (query , 10 )
620
+
621
+ query = index .parse_query ("about" , ["title" ])
622
+ result = index .searcher ().search (query , 10 )
623
+ assert len (result .hits ) == 1
624
+
599
625
600
626
class TestUpdateClass (object ):
601
627
def test_delete_update (self , ram_index ):
You can’t perform that action at this time.
0 commit comments