diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/QueryBuilderElasticSearchExport.tsx b/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/QueryBuilderElasticSearchExport.tsx index 36304ccc3f..e0f2a7ce51 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/QueryBuilderElasticSearchExport.tsx +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/QueryBuilderElasticSearchExport.tsx @@ -397,7 +397,8 @@ export function wildcardQuery(fieldName: string, matchValue: any, keywordSupport return { wildcard: { [keywordSupport ? fieldName + ".keyword" : fieldName]: { - value: `*${matchValue}*` + value: `*${matchValue}*`, + case_insensitive: true } } }; diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/__tests__/__snapshots__/QueryBuilderElasticSearchExport.test.tsx.snap b/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/__tests__/__snapshots__/QueryBuilderElasticSearchExport.test.tsx.snap index 6c73f72266..00e6e0da83 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/__tests__/__snapshots__/QueryBuilderElasticSearchExport.test.tsx.snap +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-elastic-search/__tests__/__snapshots__/QueryBuilderElasticSearchExport.test.tsx.snap @@ -228,6 +228,7 @@ exports[`QueryBuilderElasticSearchExport functionality Query helper functions wi Object { "wildcard": Object { "fieldTest": Object { + "case_insensitive": true, "value": "*valueToMatch*", }, }, @@ -238,6 +239,7 @@ exports[`QueryBuilderElasticSearchExport functionality Query helper functions wi Object { "wildcard": Object { "fieldTest.keyword": Object { + "case_insensitive": true, "value": "*valueToMatch*", }, }, diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/QueryBuilderTextSearch.test.tsx b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/QueryBuilderTextSearch.test.tsx index bb918c751f..952691a0e1 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/QueryBuilderTextSearch.test.tsx +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/QueryBuilderTextSearch.test.tsx @@ -214,6 +214,62 @@ describe("QueryBuilderTextSearch", () => { }); }); + describe("contains (wildcard) operation", () => { + test("With relationship as field", async () => { + expect( + transformTextSearchToDSL({ + operation: "wildcard", + value: "text search", + fieldInfo: { + label: "name", + value: "collection.name", + type: "text", + path: "attributes", + parentName: "collection", + parentType: "collection", + parentPath: "included", + distinctTerm: true, + keywordMultiFieldSupport: true + } as any, + fieldPath: "included.attributes.name", + queryType: "wildcard" + }) + ).toMatchSnapshot(); + }); + + test("With relationship containing complex path as field", async () => { + expect( + transformTextSearchToDSL({ + operation: "wildcard", + value: "text", + fieldInfo: { + label: "determination.scientificName", + parentName: "organism", + parentPath: "included", + parentType: "organism", + path: "attributes.determination", + type: "text", + value: "organism.determination.scientificName" + } as any, + fieldPath: "included.attributes.determination.scientificName", + queryType: "wildcard" + }) + ).toMatchSnapshot(); + }); + + test("Normal field", async () => { + expect( + transformTextSearchToDSL({ + operation: "wildcard", + value: "text search", + fieldInfo: {} as any, + fieldPath: "data.attributes.textField", + queryType: "wildcard" + }) + ).toMatchSnapshot(); + }); + }); + describe("ContainsText (Infix) operation", () => { test("With relationship as field", async () => { expect( diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderFieldExtensionSearch.test.tsx.snap b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderFieldExtensionSearch.test.tsx.snap index ae821c746d..0a403627b0 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderFieldExtensionSearch.test.tsx.snap +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderFieldExtensionSearch.test.tsx.snap @@ -94,6 +94,7 @@ exports[`QueryBuilderManagedAttributeSearch transformFieldExtensionToDSL functio Object { "wildcard": Object { "data.attributes.extensionValues.extension.field.keyword": Object { + "case_insensitive": true, "value": "*test123*", }, }, @@ -316,6 +317,7 @@ Object { Object { "wildcard": Object { "included.attributes.extensionValues.extension.field.keyword": Object { + "case_insensitive": true, "value": "*test123*", }, }, diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderManagedAttributeSearch.test.tsx.snap b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderManagedAttributeSearch.test.tsx.snap index 5fcb008b61..6f3999c82d 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderManagedAttributeSearch.test.tsx.snap +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderManagedAttributeSearch.test.tsx.snap @@ -1605,6 +1605,7 @@ exports[`QueryBuilderManagedAttributeSearch transformManagedAttributeToDSL funct Object { "wildcard": Object { "data.attributes.managedAttributes.attributeName.keyword": Object { + "case_insensitive": true, "value": "*stringValue*", }, }, @@ -1827,6 +1828,7 @@ Object { Object { "wildcard": Object { "included.attributes.managedAttributes.attributeName.keyword": Object { + "case_insensitive": true, "value": "*stringValue*", }, }, diff --git a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderTextSearch.test.tsx.snap b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderTextSearch.test.tsx.snap index de7b5cb94e..eea3fd8ada 100644 --- a/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderTextSearch.test.tsx.snap +++ b/packages/common-ui/lib/list-page/query-builder/query-builder-value-types/__tests__/__snapshots__/QueryBuilderTextSearch.test.tsx.snap @@ -474,6 +474,71 @@ Object { } `; +exports[`QueryBuilderTextSearch transformTextSearchToDSL function contains (wildcard) operation Normal field 1`] = ` +Object { + "wildcard": Object { + "data.attributes.textField": Object { + "case_insensitive": true, + "value": "*text search*", + }, + }, +} +`; + +exports[`QueryBuilderTextSearch transformTextSearchToDSL function contains (wildcard) operation With relationship as field 1`] = ` +Object { + "nested": Object { + "path": "included", + "query": Object { + "bool": Object { + "must": Array [ + Object { + "wildcard": Object { + "included.attributes.name.keyword": Object { + "case_insensitive": true, + "value": "*text search*", + }, + }, + }, + Object { + "term": Object { + "included.type": "collection", + }, + }, + ], + }, + }, + }, +} +`; + +exports[`QueryBuilderTextSearch transformTextSearchToDSL function contains (wildcard) operation With relationship containing complex path as field 1`] = ` +Object { + "nested": Object { + "path": "included", + "query": Object { + "bool": Object { + "must": Array [ + Object { + "wildcard": Object { + "included.attributes.determination.scientificName": Object { + "case_insensitive": true, + "value": "*text*", + }, + }, + }, + Object { + "term": Object { + "included.type": "organism", + }, + }, + ], + }, + }, + }, +} +`; + exports[`QueryBuilderTextSearch transformTextSearchToDSL function startsWith (prefix) operation (Non-optimized) Normal field 1`] = ` Object { "prefix": Object {