Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions services/libs/opensearch/src/fieldTranslator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export default abstract class FieldTranslator {
return value
}

isNestedField(field: string): boolean {
return field.startsWith('nested_')
}

translateObjectToCrowd(object: unknown): unknown {
const translated = {}

Expand Down
13 changes: 12 additions & 1 deletion services/libs/opensearch/src/opensearchQueryParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,18 @@ export class OpensearchQueryParser {
} else if (translator.fieldExists(key)) {
const searchKey: string = translator.crowdToOpensearch(key)

query.bool.must.push(this.parseColumnCondition(filters[key], searchKey))
if (translator.isNestedField(searchKey)) {
// Extract the path to the nested object
const nestedPath = searchKey.split('.')[0]
query.bool.must.push({
nested: {
path: nestedPath,
query: this.parseColumnCondition(filters[key], searchKey),
},
})
} else {
query.bool.must.push(this.parseColumnCondition(filters[key], searchKey))
}
} else {
throw new Error(`Unknown field or operator: ${key}!`)
}
Expand Down