Add a record, adding completed, but query failed.

I can use the following ES6 code(worked in chrome) to reproduce this problem in the console of this app. 

Note: The app has 200 fields.

function update() {
return new Promise((resovle, reject) => {
var body = {
"requests": [
{
"method": "POST",
"api": "/k/v1/record.json",
"payload": {
"app": 12746,
"record": {
"積地結合": {
"value": "testdata"
},
"配車担当者名": {
value: "奥野"
}
}
}
},

]
};

kintone.api(kintone.api.url('/k/v1/bulkRequest', true), 'POST', body, function (resp) {
//success
console.log("Bulk request success");
resovle("Update success");

}, function (error) {
//error
console.log(error);
reject("Update error");
});
});
}

async function query() {
return new Promise((resovle, reject) => {
var query = '(配車担当者名 like "奥野") order by 配車担当者名 asc, 積日 asc, レコード番号 asc limit 500 offset 0';
kintone.api(kintone.api.url('/k/v1/records', true) + '?app=12746&query=' + query, 'GET', {}, function (resp) {
// success
console.log("Requery record count " + resp.records.length);
resovle("OK");
}, function (error) {
// error
console.log(error);
reject("Error");
});

});

}

async function delay(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Delay " + ms + " millisecond")
resolve("Delay");
}, ms);
});
}

async function test1() {
await query();
await update();
await query();

}

async function test2() {
await query();
await update();
await delay(2000);
await query();

}

test1();
// Requery record count 56
// Bulk request success
// Requery record count 56 (It is wrong, it should 57)

//test2();
// query record count 57
// Bulk request success
// Delay 2000 millisecond
// Requery record count 58 (It is right, it is the correct result)

Hi Linner,

 

In kintone, the full-text search engine is used for refinement searches, including the like API.

 

The full-text search engine is updated when a record is registered or updated, but the search result may not be correct if you execute a fetch before the update is complete.

 

In this case, test1() executes record retrieval immediately after the record is registered, so the registered records are not retrieved.

 

As a workaround, you can wait for the update to finish, so you can retrieve the record typically by waiting for the process to finish, as in test2().

 

Hopefully, this helps.

Hello,

Thanks for your quick response. I have one more question:

Besides the like API, is there any other API using the full-text search engine?

In the case of operators, “like” and “not like” are applicable since the full-text search applies to “contains/does not contain the following keywords.”

 

On the other hand, the following APIs and URLs that can specify query parameters are applicable in the case of APIs.

 

Get Records:

https://developer.kintone.io/hc/en-us/articles/360019245194

 

Bulk record retrieval using the Cursor API method:

https://developer.kintone.io/hc/en-us/articles/360000361641-Bulk-record-retrieval-using-the-Cursor-API-method

 

Specify Record List via Query String:

https://developer.kintone.io/hc/en-us/articles/212494358-Specify-Record-List-via-Query-String

 

Hopefully, this helps.