I now this is for App Search, but not sure where to post this search-ui for elasticsearch question.
In a hard way that I learned that search-ui is expecting the 'id' field in the elasticsearch index hence the response. The problem is that the index is created by another program which does not have 'id', though it has the '_id' field.
In the buildState.js file, I am able to convert '_id' to 'id', but for this reason, I have to use the 'record' instead of 'record._source'. With this, the result set returns the _source as this:
"_source": [object Object]
while 'id' is normal:
"id": cee86628eaebffb36d3378be7a94651
So, how can I get the field inside the '_source' object?
Here is the code from buildState.js:
const res = hits.map(record => {
return Object.entries(record)
.map(([fieldName, fieldValue]) => [
fieldName == "_id" ? "id" : fieldName,
toObject(fieldValue, getHighlight(record, fieldName))
])
.reduce(addEachKeyValueToObject, {});
});
Here is the state returned by buildState.js, and you can see it is an object.:
{
"id": {
"raw": "8239827cd9e538e88a03f71d2c8ae14"
},
"_index": {
"raw": "myfirstfsjob"
},
"_score": {
"raw": 9.116072
},
"_source": {
"raw": {
"content": "XXX",
"file": {
"filename": "dt4_8.pdf",
"url": "c:\\dt4_8.pdf"
}
}
}
}