Closed TisserantG closed 1 year ago
exists must work like example in : https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/#matching-array-values
Following https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/#matching-array-values I do :
const filter = { query: { "exists": 'name.hobbies["compiler"]' } } const list = await this.sdk.document.search("test","t2", filter, {lang: "koncorde"} ); console.log("list : " + JSON.stringify(list)); const list2 = await this.sdk.document.search("test","t2", {}); console.log("list2 : " + JSON.stringify(list2));
Result is :
list : {"hits":[],"fetched":0,"total":0} list2 : {"hits":[{"_id":"_EpZb4ABXNxAajr4jYQ1","_score":1,"_source":{"name":{"first":"Grace","last":"Hopper","hobbies":["compiler","COBOL"]},"_kuzzle_info":{"author":"-1","createdAt":1651135581492,"updatedAt":null,"updater":null}},"collection":"t2","index":"test"}],"fetched":1,"total":1}
list and list2 would be equals.
1. Create collection with mapping :
{ "dynamic": "false", "properties": { "name": { "properties": { "first": { "type": "keyword" }, "hobbies": { "type": "keyword" }, "last": { "type": "keyword" } } } } }
2. Create document
{ "name": { "first": "Grace", "last": "Hopper", "hobbies": [ "compiler", "COBOL" ] } }
3. Use filter
{ query: { "exists": 'name.hobbies["compiler"]' } }
Query can be done with :
{ query: { equals: { 'name.hobbies': 'compiler', }, }, }
So is is update documentation ( https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/ and https://github.com/kuzzleio/koncorde/wiki/Filter-Syntax ) may be enough.
Cases are not tested here : https://github.com/kuzzleio/kuzzle/blob/fec478770d8ce0be0a46571888292d5421433b72/test/service/storage/queryTranslator.test.js Don't forget to add tests.
Expected Behavior
exists must work like example in : https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/#matching-array-values
Current Behavior
Following https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/#matching-array-values I do :
Result is :
list and list2 would be equals.
Steps to Reproduce
1. Create collection with mapping :
2. Create document
3. Use filter
Idea
Query can be done with :
So is is update documentation ( https://docs.kuzzle.io/core/2/api/koncorde-filters-syntax/clauses/ and https://github.com/kuzzleio/koncorde/wiki/Filter-Syntax ) may be enough.