mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
feat(server): add search docs by keyword gql api (#12866)
close AI-220 #### PR Dependency Tree * **PR #12866** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new document search capability, allowing users to search for documents by keyword within a workspace. - Search results include document details such as title, highlights, creation and update timestamps, and creator/updater information. - Added support for limiting the number of search results returned. - **Tests** - Added comprehensive end-to-end and snapshot tests to ensure accuracy and access control for the new search functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1419,6 +1419,33 @@ export const indexerAggregateQuery = {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const indexerSearchDocsQuery = {
|
||||
id: 'indexerSearchDocsQuery' as const,
|
||||
op: 'indexerSearchDocs',
|
||||
query: `query indexerSearchDocs($id: String!, $input: SearchDocsInput!) {
|
||||
workspace(id: $id) {
|
||||
searchDocs(input: $input) {
|
||||
docId
|
||||
title
|
||||
blockId
|
||||
highlight
|
||||
createdAt
|
||||
updatedAt
|
||||
createdByUser {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
}
|
||||
updatedByUser {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const indexerSearchQuery = {
|
||||
id: 'indexerSearchQuery' as const,
|
||||
op: 'indexerSearch',
|
||||
|
||||
22
packages/common/graphql/src/graphql/indexer-search-docs.gql
Normal file
22
packages/common/graphql/src/graphql/indexer-search-docs.gql
Normal file
@@ -0,0 +1,22 @@
|
||||
query indexerSearchDocs($id: String!, $input: SearchDocsInput!) {
|
||||
workspace(id: $id) {
|
||||
searchDocs(input: $input) {
|
||||
docId
|
||||
title
|
||||
blockId
|
||||
highlight
|
||||
createdAt
|
||||
updatedAt
|
||||
createdByUser {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
}
|
||||
updatedByUser {
|
||||
id
|
||||
name
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2063,6 +2063,24 @@ export interface SameSubscriptionRecurringDataType {
|
||||
recurring: Scalars['String']['output'];
|
||||
}
|
||||
|
||||
export interface SearchDocObjectType {
|
||||
__typename?: 'SearchDocObjectType';
|
||||
blockId: Scalars['String']['output'];
|
||||
createdAt: Scalars['DateTime']['output'];
|
||||
createdByUser: Maybe<PublicUserType>;
|
||||
docId: Scalars['String']['output'];
|
||||
highlight: Scalars['String']['output'];
|
||||
title: Scalars['String']['output'];
|
||||
updatedAt: Scalars['DateTime']['output'];
|
||||
updatedByUser: Maybe<PublicUserType>;
|
||||
}
|
||||
|
||||
export interface SearchDocsInput {
|
||||
keyword: Scalars['String']['input'];
|
||||
/** Limit the number of docs to return, default is 20 */
|
||||
limit?: InputMaybe<Scalars['Int']['input']>;
|
||||
}
|
||||
|
||||
export interface SearchHighlight {
|
||||
before: Scalars['String']['input'];
|
||||
end: Scalars['String']['input'];
|
||||
@@ -2649,6 +2667,8 @@ export interface WorkspaceType {
|
||||
role: Permission;
|
||||
/** Search a specific table */
|
||||
search: SearchResultObjectType;
|
||||
/** Search docs by keyword */
|
||||
searchDocs: Array<SearchDocObjectType>;
|
||||
/** The team subscription of the workspace, if exists. */
|
||||
subscription: Maybe<SubscriptionType>;
|
||||
/** if workspace is team workspace */
|
||||
@@ -2700,6 +2720,10 @@ export interface WorkspaceTypeSearchArgs {
|
||||
input: SearchInput;
|
||||
}
|
||||
|
||||
export interface WorkspaceTypeSearchDocsArgs {
|
||||
input: SearchDocsInput;
|
||||
}
|
||||
|
||||
export interface WorkspaceUserType {
|
||||
__typename?: 'WorkspaceUserType';
|
||||
avatarUrl: Maybe<Scalars['String']['output']>;
|
||||
@@ -4339,6 +4363,39 @@ export type IndexerAggregateQuery = {
|
||||
};
|
||||
};
|
||||
|
||||
export type IndexerSearchDocsQueryVariables = Exact<{
|
||||
id: Scalars['String']['input'];
|
||||
input: SearchDocsInput;
|
||||
}>;
|
||||
|
||||
export type IndexerSearchDocsQuery = {
|
||||
__typename?: 'Query';
|
||||
workspace: {
|
||||
__typename?: 'WorkspaceType';
|
||||
searchDocs: Array<{
|
||||
__typename?: 'SearchDocObjectType';
|
||||
docId: string;
|
||||
title: string;
|
||||
blockId: string;
|
||||
highlight: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
createdByUser: {
|
||||
__typename?: 'PublicUserType';
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl: string | null;
|
||||
} | null;
|
||||
updatedByUser: {
|
||||
__typename?: 'PublicUserType';
|
||||
id: string;
|
||||
name: string;
|
||||
avatarUrl: string | null;
|
||||
} | null;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
|
||||
export type IndexerSearchQueryVariables = Exact<{
|
||||
id: Scalars['String']['input'];
|
||||
input: SearchInput;
|
||||
@@ -5302,6 +5359,11 @@ export type Queries =
|
||||
variables: IndexerAggregateQueryVariables;
|
||||
response: IndexerAggregateQuery;
|
||||
}
|
||||
| {
|
||||
name: 'indexerSearchDocsQuery';
|
||||
variables: IndexerSearchDocsQueryVariables;
|
||||
response: IndexerSearchDocsQuery;
|
||||
}
|
||||
| {
|
||||
name: 'indexerSearchQuery';
|
||||
variables: IndexerSearchQueryVariables;
|
||||
|
||||
Reference in New Issue
Block a user