@@ -134,6 +134,7 @@ export default function UnifiedSearch() {
134134 . then ( ( items ) => {
135135 const lineCombined = { results : [ ] } ;
136136 const bodyCombined = { results : [ ] } ;
137+ const publishedNames = new Set ( ) ;
137138
138139 const allItems = items . names
139140 . sort ( ( a , b ) => {
@@ -179,7 +180,8 @@ export default function UnifiedSearch() {
179180 match . keyType === "neuronType"
180181 ) {
181182 return match . bodyIDs . map ( ( body ) => {
182- const [ bodyID ] = Object . entries ( body ) [ 0 ] ;
183+ publishedNames . add ( body ) ;
184+ const bodyID = body . split ( ":" ) . at ( - 1 ) ;
183185 const byBodyUrl = `${ appState . dataVersion } /metadata/by_body/${ bodyID } .json` ;
184186 return Storage . get ( byBodyUrl , storageOptions )
185187 . then ( ( metaData ) =>
@@ -205,21 +207,30 @@ export default function UnifiedSearch() {
205207 allPromisses . then ( ( ) => {
206208 // remove duplicates from the combined results. This can happen if we are
207209 // loading data from a partial neurontype string, eg: WED01
208- setFoundItems ( bodyCombined . results . length ) ;
209210 if ( bodyCombined . results . length > 0 ) {
211+ // filter out duplicates
210212 const ids = bodyCombined . results . map ( ( result ) => result . id ) ;
211213 bodyCombined . results = bodyCombined . results . filter (
212214 ( { id } , index ) => ! ids . includes ( id , index + 1 ) ,
213215 ) ;
216+
217+ // filter out items that are not in the publishedNames set.
218+ if ( publishedNames . size > 0 ) {
219+ bodyCombined . results = bodyCombined . results . filter ( ( item ) => {
220+ const [ dataset , , bodyid ] = item . publishedName . split ( ":" ) ;
221+ return publishedNames . has ( item . publishedName ) ||
222+ publishedNames . has ( `${ dataset } :${ bodyid } ` ) ;
223+ } ) ;
224+ }
225+ setFoundItems ( bodyCombined . results . length ) ;
214226 // This filter ignores versions of the dataset if the searchDataset doesn't
215227 // have a colon in it. A missing colon means it does not require a match to
216228 // the dataset version, so the version is removed from the publishedName
217229 // in the match and then checked against the search term.
218230 if ( searchDataset && searchDataset . length > 0 && ! searchDataset . includes ( ":" ) ) {
219231 bodyCombined . results = bodyCombined . results . filter ( ( item ) => {
220- const [ dataset , version , bodyid ] = item . publishedName . split ( ":" ) ;
232+ const [ dataset , , bodyid ] = item . publishedName . split ( ":" ) ;
221233 const noVersion = `${ dataset } :${ bodyid } ` ;
222- console . log ( dataset , version , bodyid ) ;
223234 return noVersion . match ( searchRegex ) ;
224235 } ) ;
225236 // filter out items that don't match the original searchTerm if a
0 commit comments