Skip to content

Commit

Permalink
fix(form-builder): bump number of displayed search results for refere…
Browse files Browse the repository at this point in the history
…nce inputs
  • Loading branch information
bjoerge committed Jan 7, 2022
1 parent 7abc8c3 commit 32b4ff2
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,16 @@ export function search(
options: ReferenceFilterSearchOptions
): Observable<SearchHit[]> {
const searchWeighted = createWeightedSearch(type.to, searchClient, options)
return searchWeighted(textTerm, {includeDrafts: true, limit: 50}).pipe(
return searchWeighted(textTerm, {includeDrafts: true}).pipe(
map((results) => results.map((result) => result.hit)),
map(collate),
map((collated) => collated.slice(0, 50)),
// pick the 100 best matches
map((collated) => collated.slice(0, 100)),
mergeMap((collated) => {
const ids = getMissingIds(collated)
// note: this is a lot faster than doing the query *[_id in $ids] {_id}
const q = `{${ids.map((id) => `"${id}": defined(*[_id == "${id}"][0]._id)`).join(',')}}`
return searchClient.observable.fetch(q, {}, {tag: 'debug'}).pipe(
return searchClient.observable.fetch(q, {}, {tag: 'get-missing-ids'}).pipe(
map((result) =>
collated.map((entry) => {
const draftId = getDraftId(entry.id)
Expand Down

3 comments on commit 32b4ff2

@vercel
Copy link

@vercel vercel bot commented on 32b4ff2 Jan 7, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

studio-workshop – ./dev/workshop

studio-workshop-git-next.sanity.build
studio-workshop.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 32b4ff2 Jan 7, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 32b4ff2 Jan 7, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio-git-next.sanity.build
perf-studio.sanity.build

Please sign in to comment.