-
Notifications
You must be signed in to change notification settings - Fork 1
optionally post-process results before displaying them #50
Conversation
Hi @alastair, Thanks for the PR! The reason that the multimodal component performs two queries is to be able to show all possible filters and facets. The The |
README.md
Outdated
To start the example demo, run | ||
|
||
```bash | ||
npm run start:example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm run start:example | |
yarn start:example |
const { data: { results } } = await client.query({ | ||
query : searchType.searchQuery, | ||
variables: { | ||
filter: generateFilter(query, allResults, filtersState, this.filter), | ||
filter: generateFilter(query, processedAllResults, filtersState, this.filter), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When processSearchResult
is not defined, the generateFilter
function won't receive allResults
anymore. Doesn't this break the query without the processing functions?
I just tested this against prod and it gives me the expected results, thanks! |
One additional thought about this - because the data that we're extracting is a child of the main returned object, will the automatic filter building work? (I didn't try it in my example). Hopefully it will correctly use the result of |
@ChristiaanScheermeijer can we merge this and get a new release made? |
As described in trompamusic/ce-api#187, we sometimes have searches where the items that we want are returned as child objects of the main query, for example:
The items that we want are actually the MusicCompositions returned in
itemListElement
. This query cannot be done any other way because we don't have reverse relationships saying that an item is part of a list.This change adds optional
preprocessQuery
andprocessSearchResult
methods to search types so that we can do a query such as the one above, and then post-process the results and return a list of the expected objects.There is still a bug, where I don't understand the reasoning behind performing two queries in
SearchConfig.performSearch
- first it runssearchType.searchAllQuery
and thensearchType.searchQuery
. In the example that I made, the first result runs fine, but then the second one filters out everything, I'm sure I'm missing something simple in the data flow.I see that some ordering code appears to assume that there is a _searchScore property in some returned items, which might also not be the case here.