(mgr *cbgt.Manager, indexName, indexUUID string, req []byte, res io.Writer)
| 90 | } |
| 91 | |
| 92 | func QueryAlias(mgr *cbgt.Manager, indexName, indexUUID string, |
| 93 | req []byte, res io.Writer) error { |
| 94 | queryCtlParams := cbgt.QueryCtlParams{ |
| 95 | Ctl: cbgt.QueryCtl{ |
| 96 | Timeout: cbgt.QUERY_CTL_DEFAULT_TIMEOUT_MS, |
| 97 | }, |
| 98 | } |
| 99 | |
| 100 | err := UnmarshalJSON(req, &queryCtlParams) |
| 101 | if err != nil { |
| 102 | return fmt.Errorf("alias: QueryAlias"+ |
| 103 | " parsing queryCtlParams, err: %v", err) |
| 104 | } |
| 105 | |
| 106 | var sr *SearchRequest |
| 107 | err = UnmarshalJSON(req, &sr) |
| 108 | if err != nil { |
| 109 | return fmt.Errorf("alias: QueryAlias"+ |
| 110 | " parsing searchRequest, err: %v", err) |
| 111 | } |
| 112 | searchRequest, err := sr.ConvertToBleveSearchRequest() |
| 113 | if err != nil { |
| 114 | return fmt.Errorf("alias: QueryAlias"+ |
| 115 | " parsing searchRequest, err: %v", err) |
| 116 | } |
| 117 | |
| 118 | ctx, cancel, cancelCh := setupContextAndCancelCh(queryCtlParams, nil) |
| 119 | // defer a call to cancel, this ensures that goroutine from |
| 120 | // setupContextAndCancelCh always exits |
| 121 | defer cancel() |
| 122 | |
| 123 | alias, multiCollIndex, err := bleveIndexAliasForUserIndexAlias(mgr, |
| 124 | indexName, indexUUID, true, |
| 125 | queryCtlParams.Ctl.Consistency, cancelCh, true, |
| 126 | queryCtlParams.Ctl.PartitionSelection) |
| 127 | if err != nil { |
| 128 | return err |
| 129 | } |
| 130 | |
| 131 | searchResponse, err := alias.SearchInContext(ctx, searchRequest) |
| 132 | if err != nil { |
| 133 | return err |
| 134 | } |
| 135 | // additional processing with multi-collection indexes. |
| 136 | if multiCollIndex { |
| 137 | processAliasResponse(searchResponse) |
| 138 | } |
| 139 | |
| 140 | rest.MustEncode(res, searchResponse) |
| 141 | |
| 142 | return nil |
| 143 | } |
| 144 | |
| 145 | func processAliasResponse(searchResponse *bleve.SearchResult) { |
| 146 | if searchResponse != nil { |
nothing calls this directly
no test coverage detected