spring-projects / spring-projects/spring-data-couchbase

Await for FTS index to update

Open
#1,419 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: feedback-provided
Dominant language
Java
Stars
284
Forks
197
PR merge metrics
No merged PRs in 30d

Description

When writing tests that involve the FTS engine, I'm stuck with stone age technique of thread cpu-busy loop to wait the FTS engine to index my documents.

I have tried the following :

int retry = 0;

while (cluster.searchQuery("myIndex", SearchQuery.docId(myDocument.getId())).rows().isEmpty()) {
    if (retry > 60) fail("Document indexation in FTS timeout");
    Thread.sleep(1000);
    retry++;
}

But it gave me inconsistent results. I guess it waits for the index to acknowledge the document but the document is not yet ready to be searched. Sometimes, on a small sized machine overwhelmed by test suites, a dozen of seconds can separate acknowledgement from readiness.

Is there a common wait to deal with this ?

Edit : in my tests I'm using FTS inside a N1QL query, I don't know if that matters.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the cluster.searchQuery and SearchQuery.docId entry points used in the example, including their use from N1QL queries. Determine how tests can reliably wait for FTS results rather than using a CPU-busy loop; done means a consistent waiting approach for indexed documents.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.