fix(aio): relax search on titles further

This change will now match `ControlValueAccessor` for the query `accessor`.

Closes #18872
This commit is contained in:
Peter Bacon Darwin 2017-09-09 18:15:46 +01:00 committed by Matias Niemelä
parent a2b50ec8c9
commit 5cd0d6ab25
3 changed files with 6 additions and 2 deletions

View File

@ -96,6 +96,8 @@ describe('site App', function() {
it('should find pages when searching by a partial word in the title', () => { it('should find pages when searching by a partial word in the title', () => {
page.enterSearch('ngCont'); page.enterSearch('ngCont');
expect(page.getSearchResults().map(link => link.getText())).toContain('NgControl'); expect(page.getSearchResults().map(link => link.getText())).toContain('NgControl');
page.enterSearch('accessor');
expect(page.getSearchResults().map(link => link.getText())).toContain('ControlValueAccessor');
}); });
}); });
}); });

View File

@ -51,7 +51,9 @@ export class SitePage {
} }
enterSearch(query: string) { enterSearch(query: string) {
element(by.css('.search-container input[type=search]')).sendKeys(query); const input = element(by.css('.search-container input[type=search]'));
input.clear();
input.sendKeys(query);
} }
getSearchResults() { getSearchResults() {

View File

@ -88,7 +88,7 @@ function queryIndex(query) {
if (query.length) { if (query.length) {
// Add a relaxed search in the title for the first word in the query // Add a relaxed search in the title for the first word in the query
// E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*" // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
var titleQuery = 'titleWords:' + query.split(' ', 1)[0] + '*'; var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
var results = index.search(query + ' ' + titleQuery); var results = index.search(query + ' ' + titleQuery);
// Map the hits into info about each page to be returned as results // Map the hits into info about each page to be returned as results
return results.map(function(hit) { return pages[hit.ref]; }); return results.map(function(hit) { return pages[hit.ref]; });