Skip to content

Commit

Permalink
fix(search): include text type fields in search queries (#6895)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Jun 11, 2024
1 parent 08f79a4 commit 5e505ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ describe('deriveSearchWeightsFromType', () => {
preview: {select: {}},
fields: [
defineField({name: 'simpleStringField', type: 'string'}),
defineField({name: 'descriptionTextField', type: 'text'}),
defineField({name: 'markdownField', type: 'markdown'}),
defineField({
name: 'simplePtField',
type: 'array',
Expand Down Expand Up @@ -83,6 +85,10 @@ describe('deriveSearchWeightsFromType', () => {
}),
],
}),
defineType({
name: 'markdown',
type: 'text',
}),
],
})

Expand All @@ -97,6 +103,8 @@ describe('deriveSearchWeightsFromType', () => {
{path: '_id', weight: 1},
{path: '_type', weight: 1},
{path: 'simpleStringField', weight: 1},
{path: 'descriptionTextField', weight: 1},
{path: 'markdownField', weight: 1},
{path: 'simplePtField', weight: 1, mapWith: 'pt::text'},
{path: 'simpleObject.nestedStringField', weight: 1},
{path: 'simpleObject.nestedPtField', weight: 1, mapWith: 'pt::text'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const isPtField = (type: SchemaType | undefined) =>
type?.jsonType === 'array' &&
type.of.some((arrType) => getTypeChain(arrType).some(({name}) => name === 'block'))

const isStringField = (schemaType: SchemaType | undefined) =>
getTypeChain(schemaType).some((type) => type.name === 'string')
const isStringField = (schemaType: SchemaType | undefined): boolean =>
schemaType ? schemaType?.jsonType === 'string' : false

const isSearchConfiguration = (options: unknown): options is SearchConfiguration =>
isRecord(options) && 'search' in options && isRecord(options.search)
Expand Down

0 comments on commit 5e505ac

Please sign in to comment.