code: private static Observable.Transformer<AsyncN1qlQueryResult, Boolean> checkIndexCreation(final boolean ignoreIfExist,
              final String prefixMsg) {
          return new Observable.Transformer<AsyncN1qlQueryResult, Boolean>() {
              @Override
              public Observable<Boolean> call(Observable<AsyncN1qlQueryResult> sourceObservable) {
                  return sourceObservable
                          .flatMap(new Func1<AsyncN1qlQueryResult, Observable<Boolean>>() {
                              @Override
                              public Observable<Boolean> call(final AsyncN1qlQueryResult aqr) {
                                  return aqr.finalSuccess()
                                          .flatMap(new Func1<Boolean, Observable<Boolean>>() {
                                              @Override
                                              public Observable<Boolean> call(Boolean success) {
                                                  if (success) {
                                                      return Observable.just(true);
                                                  } else {
                                                      return aqr.errors()
                                                      .toList()
                                                      .flatMap(new Func1<List<JsonObject>, Observable<Boolean>>() {
                                                          @Override
                                                          public Observable<Boolean> call(List<JsonObject> errors) {
                                                              if (errors.size() == 1 && errors.get(0).getString("msg").contains("already exist")) {
                                                                  if (ignoreIfExist) {
                                                                      return Observable.just(false);
                                                                  } else {
                                                                      return Observable.error(new IndexAlreadyExistsException(prefixMsg));
                                                                  }
                                                              } else {
                                                                  return Observable.error(new CouchbaseException(prefixMsg + ": " + errors));
                                                              }
                                                          }
                                                      });
                                                  }
                                              }
                                          });
                              }
                          });
              }
          };
      }
docs: A transformer (to be used with {@link Observable#compose(Observable.Transformer)}) that takes a N1QL query result
  and inspects the status and errors.
  
  If the query succeeded, emits TRUE. If there is an error but it is only that the index exists, and ignoreIfExist
  is true, emits FALSE. Otherwise the error is propagated as a CouchbaseException.