File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed 
qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules 
src/main/java/org/elasticsearch/xpack/application/rules Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ setup :
2+   - do :
3+       bulk :
4+         refresh : true 
5+         index : test-index1 
6+         body :
7+           - index :
8+               _id : foo 
9+           - { "text": "foo - pinned doc for foo" } 
10+ 
11+ ---
12+ " query rules retriever when the .query-rules system index is missing "  :
13+   - skip :
14+       features : [ headers ] 
15+   - do :
16+       search :
17+         index : test-index1 
18+         body :
19+           retriever :
20+             rule :
21+               match_criteria :
22+                 foo : foo 
23+                 bar : bar 
24+               ruleset_ids :
25+                 abc 
26+               retriever :
27+                 standard :
28+                   query :
29+                     query_string :
30+                       query : bar 
31+           explain : true 
32+       catch : " missing" 
Original file line number Diff line number Diff line change @@ -252,8 +252,15 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) {
252252
253253                    for  (MultiGetItemResponse  item  : multiGetResponse ) {
254254                        String  rulesetId  = item .getId ();
255+                         // this usually happens when the system index does not exist because no query rules were created yet 
256+                         if  (item .isFailed ()) {
257+                             listener .onFailure (item .getFailure ().getFailure ());
258+                             return ;
259+                         }
260+ 
255261                        GetResponse  getResponse  = item .getResponse ();
256262
263+                         // this happens when an individual query ruleset cannot be found 
257264                        if  (getResponse .isExists () == false ) {
258265                            listener .onFailure (new  ResourceNotFoundException ("query ruleset "  + rulesetId  + " not found" ));
259266                            return ;
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments