question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Await for FTS index to update

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mikereichecommented, Apr 22, 2022

Use this url curl -u <username>:<password> http://<ip>:8094/api/nsstats

check for bucket_name:index_name:num_mutations_to_index = 0. In the unit tests, we use okhttp client for things like this.

{
  "batch_bytes_added": 13198,
  "batch_bytes_removed": 13198,
  "curr_batches_blocked_by_herder": 0,
  "my_bucket:myTestIndex:avg_grpc_internal_queries_latency": 0,
.
.
.
  "my_bucket:myTestIndex:num_files_on_disk": 4,
  "my_bucket:myTestIndex:num_mutations_to_index": 0,
0reactions
mikereichecommented, Oct 4, 2022

“This requires the latest token from the last insert ?” I don’t believe the order that documents are inserted can be inferred from the order they were inserted. And even if they could, if the inserts are done with the reactive API, there’s no way to know the order the inserts actually occurred. One could look at the CAS, but then again, that’s another assumption.

As I mentioned earlier, there is the “num_mutations_to_index”. That will be zero when all mutations have been indexed. Is that not sufficient?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What criteria(s) trigger the Full Text Search Index re-built?
Hey @jessyang, on new mutations the FTS index will continually be updated (it isn't re-built). When the index is building, search requests/ ...
Read more >
How to automatically maintain Full-Text indexes and catalogs
We want to parameter the solution as much as possible so that we can easily change its behavior without changing the code. Available...
Read more >
Improve the Performance of Full-Text Indexes - SQL Server
If the average disk-waiting queue length is more than two times the ... More important, update the statistics on the clustered index or...
Read more >
How to refresh a full text index from within a SQL Server ...
I think you're out of luck. Trying to start a manual refresh inside a transaction... begin tran alter fulltext index on dbo.FTS_Table start ......
Read more >
14.6.2.3 InnoDB Full-Text Indexes - MySQL :: Developer Zone
Specifically, updates and insertions on a full-text index are processed at transaction commit time, which means that a full-text search can only see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found