File tree 1 file changed +17
-7
lines changed
src/Nest/Domain/Observers
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)
51
51
if ( ! createIndexResponse . IsValid )
52
52
throw new ReindexException ( createIndexResponse . ConnectionStatus ) ;
53
53
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 )
59
69
. From ( 0 )
60
70
. Size ( size )
61
71
. Query ( this . _reindexDescriptor . _QuerySelector ?? ( q=> q . MatchAll ( ) ) )
62
72
. SearchType ( SearchType . Scan )
63
- . Scroll ( scroll )
64
- ) ;
73
+ . Scroll ( scroll ) ) ;
74
+
65
75
if ( searchResult . Total <= 0 )
66
76
throw new ReindexException ( searchResult . ConnectionStatus , "index " + fromIndex + " has no documents!" ) ;
67
77
IBulkResponse indexResult = null ;
You can’t perform that action at this time.
0 commit comments