Skip to content

Commit

Permalink
change SO provider to prefix search
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Aug 17, 2020
1 parent 436a28a commit e1672e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('savedObjectsResultProvider', () => {
expect(context.core.savedObjects.client.find).toHaveBeenCalledWith({
page: 1,
perPage: defaultOption.maxResults,
search: 'term',
search: 'term*',
preference: 'pref',
searchFields: ['title', 'description'],
type: ['typeA', 'typeB'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createSavedObjectsResultProvider = (): GlobalSearchResultProvider =
const responsePromise = client.find({
page: 1,
perPage: maxResults,
search: term,
search: term ? `${term}*` : undefined,
preference,
searchFields,
type: searchableTypes.map((type) => type.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(results.length).to.be(1);
expect(results[0].type).to.be('index-pattern');
expect(results[0].title).to.be('logstash-*');
expect(results[0].score).to.be.greaterThan(1);
expect(results[0].score).to.be.greaterThan(0.9);
});

it('can search for visualizations', async () => {
Expand Down Expand Up @@ -70,5 +70,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(results.map((r) => r.title)).to.contain('dashboard with map');
expect(results.map((r) => r.title)).to.contain('Amazing Dashboard');
});

it('can search by prefix', async () => {
const results = await findResultsWithAPI('Amaz');
expect(results.length).to.be(1);
expect(results[0].type).to.be('dashboard');
expect(results[0].title).to.be('Amazing Dashboard');
});
});
}

0 comments on commit e1672e6

Please sign in to comment.