File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
src/Nest/Domain/Observers Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -51,17 +51,27 @@ private void Reindex(IObserver<IReindexResponse<T>> observer)
5151 if ( ! createIndexResponse . IsValid )
5252 throw new ReindexException ( createIndexResponse . ConnectionStatus ) ;
5353
54- var page = 0 ;
55- var searchResult = this . CurrentClient . Search < T > (
56- s => s
57- . Index ( fromIndex )
58- . AllTypes ( )
54+ var page = 0 ;
55+ Func < SearchDescriptor < T > , SearchDescriptor < T > > searchDescriptor = s => s . Index ( fromIndex ) ;
56+
57+ if ( typeof ( T ) . Name . Equals ( typeof ( object ) . Name ) )
58+ {
59+ searchDescriptor = s => searchDescriptor ( s ) . AllTypes ( ) ;
60+ }
61+ else
62+ {
63+ searchDescriptor = s => searchDescriptor ( s ) . Type < T > ( ) ;
64+ }
65+
66+
67+ var searchResult = this . CurrentClient . Search < T > (
68+ s => searchDescriptor ( s )
5969 . From ( 0 )
6070 . Size ( size )
6171 . Query ( this . _reindexDescriptor . _QuerySelector ?? ( q=> q . MatchAll ( ) ) )
6272 . SearchType ( SearchType . Scan )
63- . Scroll ( scroll )
64- ) ;
73+ . Scroll ( scroll ) ) ;
74+
6575 if ( searchResult . Total <= 0 )
6676 throw new ReindexException ( searchResult . ConnectionStatus , "index " + fromIndex + " has no documents!" ) ;
6777 IBulkResponse indexResult = null ;
You can’t perform that action at this time.
0 commit comments