(queryCtlParams *cbgt.QueryCtlParams, indexName string, searchResult *bleve.SearchResult, remoteClients []RemoteClient, searchErr, aliasErr error)
| 1353 | } |
| 1354 | |
| 1355 | func processSearchResult(queryCtlParams *cbgt.QueryCtlParams, indexName string, |
| 1356 | searchResult *bleve.SearchResult, remoteClients []RemoteClient, |
| 1357 | searchErr, aliasErr error) error { |
| 1358 | if searchResult != nil { |
| 1359 | if len(searchResult.Hits) > 0 { |
| 1360 | // if this is a multi collection index, then strip the collection UID |
| 1361 | // from the hit ID and fill the details of source collection |
| 1362 | if sdm, multiCollIndex := |
| 1363 | metaFieldValCache.getSourceDetailsMap(indexName); multiCollIndex { |
| 1364 | for _, hit := range searchResult.Hits { |
| 1365 | if _, exists := hit.Fields["_$c"]; exists { |
| 1366 | // collection name has already been retrieved for this hit; |
| 1367 | // on the non-coordinating node (scatter-gather) |
| 1368 | continue |
| 1369 | } |
| 1370 | idBytes := []byte(hit.ID) |
| 1371 | cuid := binary.LittleEndian.Uint32(idBytes[:4]) |
| 1372 | if collName, ok := sdm.collUIDNameMap[cuid]; ok { |
| 1373 | hit.ID = string(idBytes[4:]) |
| 1374 | if hit.Fields == nil { |
| 1375 | hit.Fields = make(map[string]interface{}) |
| 1376 | } |
| 1377 | hit.Fields["_$c"] = collName |
| 1378 | } |
| 1379 | } |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | // check to see if any of the remote searches returned anything |
| 1384 | // other than 0, 200, 412, 429, these are returned to the user as |
| 1385 | // error status 400, and appear as phase 0 errors detected late. |
| 1386 | // 0 means we never heard anything back, and that is dealt with |
| 1387 | // in the following section |
| 1388 | for _, remoteClient := range remoteClients { |
| 1389 | lastStatus, lastErrBody := remoteClient.GetLast() |
| 1390 | if lastStatus == http.StatusTooManyRequests { |
| 1391 | log.Printf("bleve: remoteClient: %s query reject, statusCode: %d,"+ |
| 1392 | " err: %v", remoteClient.GetHostPort(), lastStatus, searchErr) |
| 1393 | continue |
| 1394 | } |
| 1395 | if lastStatus != http.StatusOK && |
| 1396 | lastStatus != http.StatusPreconditionFailed && |
| 1397 | lastStatus != 0 { |
| 1398 | return fmt.Errorf("bleve: QueryBleve remote client"+ |
| 1399 | " returned status: %d body: %s", lastStatus, lastErrBody) |
| 1400 | } |
| 1401 | } |
| 1402 | // now see if any of the remote searches returned 412; these should be |
| 1403 | // collated into a single 412 response at this level and will |
| 1404 | // be presented as phase 1 errors detected late |
| 1405 | remoteConsistencyWaitError := cbgt.ErrorConsistencyWait{ |
| 1406 | Status: "remote consistency error", |
| 1407 | StartEndSeqs: make(map[string][]uint64), |
| 1408 | } |
| 1409 | numRemoteSilent := 0 |
| 1410 | for _, remoteClient := range remoteClients { |
| 1411 | lastStatus, lastErrBody := remoteClient.GetLast() |
| 1412 | if lastStatus == 0 { |
no test coverage detected