@@ -702,7 +702,7 @@ public void AlterAdd()
702702 IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
703703 db . Execute ( "FLUSHALL" ) ;
704704 var ft = db . FT ( ) ;
705- Schema sc = new Schema ( ) . AddTextField ( "title" , 1.0 , sortable : true , unf : true ) ;
705+ Schema sc = new Schema ( ) . AddTextField ( "title" , 1.0 ) ;
706706
707707 Assert . True ( ft . Create ( index , FTCreateParams . CreateParams ( ) , sc ) ) ;
708708
@@ -733,9 +733,10 @@ public void AlterAdd()
733733 Assert . Equal ( index , info . IndexName ) ;
734734 Assert . Empty ( info . IndexOption ) ;
735735 // Assert.Equal(,info.IndexDefinition);
736- Assert . Equal ( "title" , ( info . Attributes [ 0 ] [ "identifier" ] ) . ToString ( ) ) ;
737- Assert . Equal ( "TAG" , ( info . Attributes [ 1 ] [ "type" ] ) . ToString ( ) ) ;
738- Assert . Equal ( "name" , ( info . Attributes [ 2 ] [ "attribute" ] ) . ToString ( ) ) ;
736+ Assert . Equal ( "title" , info . Attributes [ 0 ] [ "identifier" ] . ToString ( ) ) ;
737+ Assert . Equal ( "TAG" , info . Attributes [ 1 ] [ "type" ] . ToString ( ) ) ;
738+ Assert . Equal ( "name" , info . Attributes [ 2 ] [ "attribute" ] . ToString ( ) ) ;
739+
739740 Assert . Equal ( 100 , info . NumDocs ) ;
740741 Assert . NotNull ( info . MaxDocId ) ;
741742 Assert . Equal ( 102 , info . NumTerms ) ;
@@ -795,9 +796,135 @@ public async Task AlterAddAsync()
795796
796797 var info = await ft . InfoAsync ( index ) ;
797798 Assert . Equal ( index , info . IndexName ) ;
798- Assert . Equal ( "title" , ( info . Attributes [ 0 ] [ "identifier" ] ) . ToString ( ) ) ;
799- Assert . Equal ( "TAG" , ( info . Attributes [ 1 ] [ "type" ] ) . ToString ( ) ) ;
800- Assert . Equal ( "name" , ( info . Attributes [ 2 ] [ "attribute" ] ) . ToString ( ) ) ;
799+ Assert . Equal ( "title" , info . Attributes [ 0 ] [ "identifier" ] . ToString ( ) ) ;
800+ Assert . Equal ( "TAG" , info . Attributes [ 1 ] [ "type" ] . ToString ( ) ) ;
801+ Assert . Equal ( "name" , info . Attributes [ 2 ] [ "attribute" ] . ToString ( ) ) ;
802+ Assert . Equal ( 100 , info . NumDocs ) ;
803+ Assert . Equal ( "300" , info . MaxDocId ) ;
804+ Assert . Equal ( 102 , info . NumTerms ) ;
805+ Assert . True ( info . NumRecords >= 200 ) ;
806+ Assert . True ( info . InvertedSzMebibytes < 1 ) ; // TODO: check this line and all the <1 lines
807+ Assert . Equal ( 0 , info . VectorIndexSzMebibytes ) ;
808+ Assert . Equal ( 208 , info . TotalInvertedIndexBlocks ) ;
809+ Assert . True ( info . OffsetVectorsSzMebibytes < 1 ) ;
810+ Assert . True ( info . DocTableSizeMebibytes < 1 ) ;
811+ Assert . Equal ( 0 , info . SortableValueSizeMebibytes ) ;
812+ Assert . True ( info . KeyTableSizeMebibytes < 1 ) ;
813+ Assert . Equal ( 8 , ( int ) info . RecordsPerDocAvg ) ;
814+ Assert . True ( info . BytesPerRecordAvg > 5 ) ;
815+ Assert . True ( info . OffsetsPerTermAvg > 0.8 ) ;
816+ Assert . Equal ( 8 , info . OffsetBitsPerRecordAvg ) ;
817+ Assert . Equal ( 0 , info . HashIndexingFailures ) ;
818+ Assert . True ( info . TotalIndexingTime > 0 ) ;
819+ Assert . Equal ( 0 , info . Indexing ) ;
820+ Assert . Equal ( 1 , info . PercentIndexed ) ;
821+ Assert . Equal ( 4 , info . NumberOfUses ) ;
822+ Assert . Equal ( 7 , info . GcStats . Count ) ;
823+ Assert . Equal ( 4 , info . CursorStats . Count ) ;
824+ }
825+
826+ [ SkipIfRedis ( Is . OSSCluster , Is . Enterprise ) ]
827+ public void AlterAddSortable ( )
828+ {
829+ IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
830+ db . Execute ( "FLUSHALL" ) ;
831+ var ft = db . FT ( ) ;
832+ Schema sc = new Schema ( ) . AddTextField ( "title" , 1.0 , sortable : true ) ;
833+
834+ Assert . True ( ft . Create ( index , FTCreateParams . CreateParams ( ) , sc ) ) ;
835+
836+ //sleep:
837+ System . Threading . Thread . Sleep ( 2000 ) ;
838+
839+ var fields = new HashEntry ( "title" , "hello world" ) ;
840+ //fields.("title", "hello world");
841+ for ( int i = 0 ; i < 100 ; i ++ )
842+ {
843+ db . HashSet ( $ "doc{ i } ", fields . Name , fields . Value ) ;
844+ }
845+ SearchResult res = ft . Search ( index , new Query ( "hello world" ) ) ;
846+ Assert . Equal ( 100 , res . TotalResults ) ;
847+
848+ Assert . True ( ft . Alter ( index , new Schema ( ) . AddTagField ( "tags" ) . AddTextField ( "name" , weight : 0.5 ) ) ) ;
849+ for ( int i = 0 ; i < 100 ; i ++ )
850+ {
851+ var fields2 = new HashEntry [ ] { new ( "name" , "name" + i ) ,
852+ new ( "tags" , $ "tagA,tagB,tag{ i } ") } ;
853+ // assertTrue(client.updateDocument(string.format("doc%d", i), 1.0, fields2));
854+ db . HashSet ( $ "doc{ i } ", fields2 ) ;
855+ }
856+ SearchResult res2 = ft . Search ( index , new Query ( "@tags:{tagA}" ) ) ;
857+ Assert . Equal ( 100 , res2 . TotalResults ) ;
858+
859+ var info = ft . Info ( index ) ;
860+ Assert . Equal ( index , info . IndexName ) ;
861+ Assert . Empty ( info . IndexOption ) ;
862+ // Assert.Equal(,info.IndexDefinition);
863+ Assert . Equal ( "title" , info . Attributes [ 0 ] [ "identifier" ] . ToString ( ) ) ;
864+ Assert . Equal ( "TAG" , info . Attributes [ 1 ] [ "type" ] . ToString ( ) ) ;
865+ Assert . Equal ( "name" , info . Attributes [ 2 ] [ "attribute" ] . ToString ( ) ) ;
866+ Assert . Equal ( 100 , info . NumDocs ) ;
867+ Assert . NotNull ( info . MaxDocId ) ;
868+ Assert . Equal ( 102 , info . NumTerms ) ;
869+ Assert . True ( info . NumRecords >= 200 ) ;
870+ Assert . True ( info . InvertedSzMebibytes < 1 ) ; // TODO: check this line and all the <1 lines
871+ Assert . Equal ( 0 , info . VectorIndexSzMebibytes ) ;
872+ Assert . Equal ( 208 , info . TotalInvertedIndexBlocks ) ;
873+ Assert . True ( info . OffsetVectorsSzMebibytes < 1 ) ;
874+ Assert . True ( info . DocTableSizeMebibytes < 1 ) ;
875+ Assert . Equal ( 0 , info . SortableValueSizeMebibytes ) ;
876+ Assert . True ( info . KeyTableSizeMebibytes < 1 ) ;
877+ Assert . Equal ( 8 , ( int ) info . RecordsPerDocAvg ) ;
878+ Assert . True ( info . BytesPerRecordAvg > 5 ) ;
879+ Assert . True ( info . OffsetsPerTermAvg > 0.8 ) ;
880+ Assert . Equal ( 8 , info . OffsetBitsPerRecordAvg ) ;
881+ Assert . Equal ( 0 , info . HashIndexingFailures ) ;
882+ Assert . True ( info . TotalIndexingTime > 0 ) ;
883+ Assert . Equal ( 0 , info . Indexing ) ;
884+ Assert . Equal ( 1 , info . PercentIndexed ) ;
885+ Assert . Equal ( 4 , info . NumberOfUses ) ;
886+ Assert . Equal ( 7 , info . GcStats . Count ) ;
887+ Assert . Equal ( 4 , info . CursorStats . Count ) ;
888+ }
889+
890+ [ SkipIfRedis ( Is . OSSCluster , Is . Enterprise ) ]
891+ public async Task AlterAddSortableAsync ( )
892+ {
893+ IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
894+ db . Execute ( "FLUSHALL" ) ;
895+ var ft = db . FT ( ) ;
896+ Schema sc = new Schema ( ) . AddTextField ( "title" , 1.0 , sortable : true ) ;
897+
898+ Assert . True ( ft . Create ( index , FTCreateParams . CreateParams ( ) , sc ) ) ;
899+
900+ //sleep:
901+ System . Threading . Thread . Sleep ( 2000 ) ;
902+
903+ var fields = new HashEntry ( "title" , "hello world" ) ;
904+ //fields.("title", "hello world");
905+ for ( int i = 0 ; i < 100 ; i ++ )
906+ {
907+ db . HashSet ( $ "doc{ i } ", fields . Name , fields . Value ) ;
908+ }
909+ SearchResult res = ft . Search ( index , new Query ( "hello world" ) ) ;
910+ Assert . Equal ( 100 , res . TotalResults ) ;
911+
912+ Assert . True ( await ft . AlterAsync ( index , new Schema ( ) . AddTagField ( "tags" ) . AddTextField ( "name" , weight : 0.5 ) ) ) ;
913+ for ( int i = 0 ; i < 100 ; i ++ )
914+ {
915+ var fields2 = new HashEntry [ ] { new ( "name" , "name" + i ) ,
916+ new ( "tags" , $ "tagA,tagB,tag{ i } ") } ;
917+ // assertTrue(client.updateDocument(string.format("doc%d", i), 1.0, fields2));
918+ db . HashSet ( $ "doc{ i } ", fields2 ) ;
919+ }
920+ SearchResult res2 = ft . Search ( index , new Query ( "@tags:{tagA}" ) ) ;
921+ Assert . Equal ( 100 , res2 . TotalResults ) ;
922+
923+ var info = await ft . InfoAsync ( index ) ;
924+ Assert . Equal ( index , info . IndexName ) ;
925+ Assert . Equal ( "title" , info . Attributes [ 0 ] [ "identifier" ] . ToString ( ) ) ;
926+ Assert . Equal ( "TAG" , info . Attributes [ 1 ] [ "type" ] . ToString ( ) ) ;
927+ Assert . Equal ( "name" , info . Attributes [ 2 ] [ "attribute" ] . ToString ( ) ) ;
801928 Assert . Equal ( 100 , info . NumDocs ) ;
802929 Assert . Equal ( "300" , info . MaxDocId ) ;
803930 Assert . Equal ( 102 , info . NumTerms ) ;
0 commit comments