| 347 | } |
| 348 | |
| 349 | pub fn synonym_phrase_matches( |
| 350 | &self, |
| 351 | repo_ids: &RepoIds, |
| 352 | name: &str, |
| 353 | ) -> Result<BTreeSet<SynonymMatch>> { |
| 354 | let phrase = Phrase::parse(name); |
| 355 | let mut matches = BTreeSet::new(); |
| 356 | |
| 357 | for &repo_id in repo_ids.iter() { |
| 358 | let key = repo_id.index_key(&phrase)?; |
| 359 | for entry in &key |
| 360 | .synonym_index(self, IndexType::SynonymPhrase, IndexMode::Update)? |
| 361 | .full_matches(&phrase)? |
| 362 | { |
| 363 | if !self.viewer.can_read(repo_id) { |
| 364 | continue; |
| 365 | } |
| 366 | |
| 367 | if let Some(topic) = self.fetch_topic(repo_id, &entry.id) { |
| 368 | matches.insert(SynonymMatch { |
| 369 | cycle: false, |
| 370 | entry: (*entry).clone(), |
| 371 | name: name.to_string(), |
| 372 | repo_id, |
| 373 | repo_topic: topic, |
| 374 | }); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | Ok(matches) |
| 380 | } |
| 381 | |
| 382 | // The "prefix" argument tells us which repo to look in. The "prefix" in the method name |
| 383 | // alludes to the prefix scan that is done to find matching synonyms. |