Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposed new search lexicons #1594

Merged
merged 11 commits into from
Sep 25, 2023
13 changes: 10 additions & 3 deletions lexicons/app/bsky/actor/searchActors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
"defs": {
"main": {
"type": "query",
"description": "Find actors matching search criteria.",
"description": "Find actors (profiles) matching search criteria.",
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would support phasing out term and phasing in q

I think "term" makes sense when it's simple search on a word & no additional syntax is allowed

q fits nicely when we allow for special query syntax (like Lucene syntax)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, I updated all the instances of 'term' as a search query with 'q', and marked the old 'term' fields as "DEPRECATED" in description. This impacted an admin route as well. Idea is that for a short transition we'll fall back to "term" if "q" is empty, and maybe eventually nuke them (if/when we are feeling comfortable breaking query params in Lexicons in a small way, like a v1.0 release)

Copy link
Collaborator

@dholms dholms Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup that works 👍

"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
"default": 25
},
"cursor": { "type": "string" }
}
Expand Down
11 changes: 9 additions & 2 deletions lexicons/app/bsky/actor/searchActorsTypeahead.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": {
"type": "string",
"description": "search query prefix; not a full query string"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
"default": 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice i dig both of these new defaults 👍

}
}
},
Expand Down
52 changes: 52 additions & 0 deletions lexicons/app/bsky/feed/searchPosts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "app.bsky.feed.searchPosts",
"defs": {
"main": {
"type": "query",
"description": "Find posts matching search criteria",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["posts"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"posts": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.feed.defs#postView"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
20 changes: 20 additions & 0 deletions lexicons/app/bsky/unspecced/defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.defs",
"defs": {
"skeletonSearchPost": {
"type": "object",
"required": ["uri"],
"properties": {
"uri": { "type": "string", "format": "at-uri" }
}
},
"skeletonSearchActor": {
"type": "object",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
}
}
}
56 changes: 56 additions & 0 deletions lexicons/app/bsky/unspecced/searchActorsSkeleton.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.searchActorsSkeleton",
"defs": {
"main": {
"type": "query",
"description": "Backend Actors (profile) search, returning only skeleton",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. For typeahead search, only simple term match is supported, not full syntax"
},
"typeahead": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to use a non-normative parameter for this? something like simple or quick?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I feel like typeahead is pretty term-of-art for this query type (not just the term we are using). different sub-set of fields are queried, and only really works for prefix of a single token or two, character-by-character.

"simple" or "quick" would be confusing to me, i'd assume that they would return un-hydrated responses or something (responses are always hydrated).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool cool - i'm game for "typeahead" 👍

"type": "boolean",
"description": "if true, acts as fast/simple 'typeahead' query"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
Comment on lines +26 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past it's proven useful to not support a cursor for typeahead search. Just wanted to note that in case it's relevant here, since both typeahead and cursor parameters can appear together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the alternative be a second endpoint just for typeahead? That feels expansive to me. I think in typeahead mode we can safely ignore the cursor param and never populate that field in the output.

}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["actors"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"actors": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.unspecced.defs#skeletonSearchActor"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
52 changes: 52 additions & 0 deletions lexicons/app/bsky/unspecced/searchPostsSkeleton.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.searchPostsSkeleton",
"defs": {
"main": {
"type": "query",
"description": "Backend Posts search, returning only skeleton",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["posts"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"posts": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.unspecced.defs#skeletonSearchPost"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
6 changes: 5 additions & 1 deletion lexicons/com/atproto/admin/searchRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": { "type": "string" },
"invitedBy": { "type": "string" },
"limit": {
"type": "integer",
Expand Down
41 changes: 41 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
import * as AppBskyFeedLike from './types/app/bsky/feed/like'
import * as AppBskyFeedPost from './types/app/bsky/feed/post'
import * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
import * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
import * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
import * as AppBskyGraphBlock from './types/app/bsky/graph/block'
import * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand All @@ -129,9 +130,12 @@ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
import * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
import * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'

export * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
export * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
Expand Down Expand Up @@ -229,6 +233,7 @@ export * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
export * as AppBskyFeedLike from './types/app/bsky/feed/like'
export * as AppBskyFeedPost from './types/app/bsky/feed/post'
export * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
export * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
export * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
export * as AppBskyGraphBlock from './types/app/bsky/graph/block'
export * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand All @@ -255,9 +260,12 @@ export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
export * as AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
export * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
export * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
export * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
export * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
export * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
export * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'

export const COM_ATPROTO_ADMIN = {
DefsTakedown: 'com.atproto.admin.defs#takedown',
Expand Down Expand Up @@ -1381,6 +1389,17 @@ export class FeedNS {
throw AppBskyFeedGetTimeline.toKnownErr(e)
})
}

searchPosts(
params?: AppBskyFeedSearchPosts.QueryParams,
opts?: AppBskyFeedSearchPosts.CallOptions,
): Promise<AppBskyFeedSearchPosts.Response> {
return this._service.xrpc
.call('app.bsky.feed.searchPosts', params, undefined, opts)
.catch((e) => {
throw AppBskyFeedSearchPosts.toKnownErr(e)
})
}
}

export class GeneratorRecord {
Expand Down Expand Up @@ -2282,4 +2301,26 @@ export class UnspeccedNS {
throw AppBskyUnspeccedGetTimelineSkeleton.toKnownErr(e)
})
}

searchActorsSkeleton(
params?: AppBskyUnspeccedSearchActorsSkeleton.QueryParams,
opts?: AppBskyUnspeccedSearchActorsSkeleton.CallOptions,
): Promise<AppBskyUnspeccedSearchActorsSkeleton.Response> {
return this._service.xrpc
.call('app.bsky.unspecced.searchActorsSkeleton', params, undefined, opts)
.catch((e) => {
throw AppBskyUnspeccedSearchActorsSkeleton.toKnownErr(e)
})
}

searchPostsSkeleton(
params?: AppBskyUnspeccedSearchPostsSkeleton.QueryParams,
opts?: AppBskyUnspeccedSearchPostsSkeleton.CallOptions,
): Promise<AppBskyUnspeccedSearchPostsSkeleton.Response> {
return this._service.xrpc
.call('app.bsky.unspecced.searchPostsSkeleton', params, undefined, opts)
.catch((e) => {
throw AppBskyUnspeccedSearchPostsSkeleton.toKnownErr(e)
})
}
}
Loading