在 N1QL 查询中间歇性地面对 "Index Not Found"
Facing "Index Not Found" intermittently in N1QL query
用例:搜索 "MAYUR" 结果出现在搜索中,但如果我搜索 "MAY" 或 "MA" 没有结果。
我已经实现了一个在 startsWith("MAY%") 上搜索的搜索。
我正在使用 couchbase 版本 4.6.3-4136-E。
报错信息如下:
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException:
Unable to execute query due to the following n1ql errors:
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
Java SDK 版本:2.5.5
我时不时遇到这个问题。
代码 运行 查询
public <T> PageImpl<T> runQuery(final Statement statement, final Expression expression, final String alias,
final Pageable pageable, final Class<T> tClazz) {
PageImpl<T> tPage = null;
try {
CompletableFuture<List<T>> entityFuture = CompletableFuture
.supplyAsync(() -> findByN1QLProjection(statement, tClazz)).exceptionally(th -> {
logger.write(new Exception(th.getMessage(), th));
return Collections.emptyList();
});
CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() -> doCount(expression, alias))
.exceptionally(th -> {
logger.write(new Exception(th.getMessage(), th));
return 0L;
});
CompletableFuture.allOf(entityFuture, countFuture).get();
tPage = new PageImpl<>(entityFuture.get(), pageable, countFuture.get());
} catch (final InterruptedException | ExecutionException ex) {
logger.write(ex);
tPage = new PageImpl<>(Collections.emptyList(), pageable, 0);
}
return tPage;
}
根本原因:
错误的执行计划被查询服务缓存并随后被使用,并且由于 index-id 不可用(因为索引被重新创建),查询不断抛出错误:'Index not found'。
解析:
清理存储的准备计划后,查询开始工作。
用例:搜索 "MAYUR" 结果出现在搜索中,但如果我搜索 "MAY" 或 "MA" 没有结果。 我已经实现了一个在 startsWith("MAY%") 上搜索的搜索。 我正在使用 couchbase 版本 4.6.3-4136-E。
报错信息如下:
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException:
Unable to execute query due to the following n1ql errors:
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
{"msg":"Index Not Found - cause: queryport.indexNotFound","code":12016}
Java SDK 版本:2.5.5
我时不时遇到这个问题。
代码 运行 查询
public <T> PageImpl<T> runQuery(final Statement statement, final Expression expression, final String alias,
final Pageable pageable, final Class<T> tClazz) {
PageImpl<T> tPage = null;
try {
CompletableFuture<List<T>> entityFuture = CompletableFuture
.supplyAsync(() -> findByN1QLProjection(statement, tClazz)).exceptionally(th -> {
logger.write(new Exception(th.getMessage(), th));
return Collections.emptyList();
});
CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() -> doCount(expression, alias))
.exceptionally(th -> {
logger.write(new Exception(th.getMessage(), th));
return 0L;
});
CompletableFuture.allOf(entityFuture, countFuture).get();
tPage = new PageImpl<>(entityFuture.get(), pageable, countFuture.get());
} catch (final InterruptedException | ExecutionException ex) {
logger.write(ex);
tPage = new PageImpl<>(Collections.emptyList(), pageable, 0);
}
return tPage;
}
根本原因: 错误的执行计划被查询服务缓存并随后被使用,并且由于 index-id 不可用(因为索引被重新创建),查询不断抛出错误:'Index not found'。
解析: 清理存储的准备计划后,查询开始工作。