A library-search procedure that identifies structural features of an unknown compound from its electron-ionization mass spectrum is described. Like other methods, this procedure first retrieves library compounds whose spectra are most similar to the spectrum of an unknown compound. It then deduces structural features of the unknown compound from the chemical structures of the retrievals. Unlike other methods, the significance of each retrieved spectrum is weighted according to its similarity to the spectrum of the unknown compound. Also, a peaks-in-common screening step serves to reduce search times and an optimized dot product function provides the match factor. If the molecular weight of the unknown compound is provided, the identification of certain substructures can be improved by including neutral loss peaks. Correlations between the presence of a substructure in a test compound and its presence among library retrievals were derived from the results of searching the NIST/EPA/NIH reference library with a 7891 compound test set. These correlations allow the estimation of probabilities of substructure occurrence and absence in an unknown compound from the results of a library search. This method may be viewed as an optimization of the K-nearest neighbor method of Isenhour and co-workers, with improvements that arise from spectrum screening, peak scaling, an optimal distance measure, a relative-distance weighting scheme, and a larger reference library.