Hi folks,
I am currently running in some weird behavior while running paginated searches using the Node.js API. From my tests it seems that the "from" parameter is not being correctly parsed. No matter the value I configure it will always start from 0-index.
For example, when I run this query on Kibana console It will return 2 hits. If I change the "from" parameter to 0 or 1, I can actually recover each entry at a time.
GET my-customers/_search
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "ju",
"fuzziness": "AUTO",
"fields": [
"firstName",
"lastName",
"email"
]
}
},
"filter": []
}
},
"size": 1,
"from": 1
}
However, when I do the same on my Node application, I always get the first hit no matter the "from" value I setup.
queryValue = 'ju';
const query = {
index: "my-customers",
from: 1,
size: 1,
body: {
"query": {
"bool": {
"must": {
"multi_match": {
"query": queryValue,
"fuzziness": "AUTO",
"fields": fields
}
},
"filter": []
}
}
},
};
try {
const result = await es.search(query);
return success(mapResult(result));
} catch (e) {
return failure({
status: false
});
}
And the mapResult function:
export const mapResult = (result) => ({
total: result.hits.total.value,
items: result.hits.hits.length > 0 && result.hits.hits.map(hit => ({
id: hit._id,
...hit._source,
})) || [],
});
Anyone else encountered such problem?
Thanks!