Skip to content
Draft
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
1 change: 1 addition & 0 deletions packages/twenty-front/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ export type QuerySearchArgs = {
includedObjectNameSingulars?: InputMaybe<Array<Scalars['String']['input']>>;
limit: Scalars['Int']['input'];
searchInput: Scalars['String']['input'];
skipIlikeFallback?: InputMaybe<Scalars['Boolean']['input']>;
};


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ArgsType, Field, Int } from '@nestjs/graphql';

import { IsArray, IsInt, IsOptional, IsString, Max } from 'class-validator';
import {
IsArray,
IsBoolean,
IsInt,
IsOptional,
IsString,
Max,
} from 'class-validator';

import { ObjectRecordFilterInput } from 'src/engine/core-modules/search/dtos/object-record-filter-input';

Expand Down Expand Up @@ -32,4 +39,11 @@ export class SearchArgs {
@Field(() => [String], { nullable: true })
@IsOptional()
excludedObjectNameSingulars?: string[];

// Exact-token lookups (phone numbers, emails) never need the ILIKE pass, and on a
// big workspace that pass is a full table scan.
@IsBoolean()
@Field(() => Boolean, { nullable: true })
@IsOptional()
skipIlikeFallback?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class SearchResolver {
includedObjectNameSingulars,
excludedObjectNameSingulars,
after,
skipIlikeFallback,
}: SearchArgs,
) {
const { flatObjectMetadataMaps, flatFieldMetadataMaps } =
Expand Down Expand Up @@ -73,6 +74,7 @@ export class SearchResolver {
includedObjectNameSingulars,
excludedObjectNameSingulars,
after,
skipIlikeFallback,
workspaceId: workspace.id,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class SearchService {
limit,
filter,
after,
skipIlikeFallback,
workspaceId,
}: {
flatObjectMetadatas: FlatObjectMetadata[];
Expand Down Expand Up @@ -134,6 +135,7 @@ export class SearchService {
limit: limit as number,
filter: filter ?? ({} as ObjectRecordFilter),
after,
skipIlikeFallback,
}),
};
},
Expand Down Expand Up @@ -210,6 +212,7 @@ export class SearchService {
limit,
filter,
after,
skipIlikeFallback,
}: {
entityManager: WorkspaceRepository<Entity>;
rolePermissionConfig?: RolePermissionConfig;
Expand All @@ -221,6 +224,7 @@ export class SearchService {
limit: number;
filter: ObjectRecordFilterInput;
after?: string;
skipIlikeFallback?: boolean;
}) {
const tsvectorResults = await this.buildSearchQueryAndGetRecords({
entityManager,
Expand All @@ -236,7 +240,8 @@ export class SearchService {
if (
tsvectorResults.length > 0 ||
!isNonEmptyString(searchInput.trim()) ||
isDefined(after)
isDefined(after) ||
skipIlikeFallback
) {
return tsvectorResults;
}
Expand Down
Loading