Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for suggestions #36

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions __test__/targets/search.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getHighlightQuery,
getQueryStringQuery,
getSearchAggregation,
getSearchQuery,
getSearchOrSuggestionQuery,
getSearchSortByQuery,
} from '../../src/targets/search';
import { ConfigType } from '../../src/types/types';
Expand Down Expand Up @@ -449,8 +449,8 @@ test('getHighlightQuery when highlight is true, dataField is a wildcard and high
expect(result).toStrictEqual(expected);
});

test('getSearchQuery when highlight is true', () => {
const result = getSearchQuery(
test('getSearchOrSuggestionQuery when highlight is true', () => {
const result = getSearchOrSuggestionQuery(
{
value: 'Apart',
dataField: 'data',
Expand Down Expand Up @@ -491,16 +491,15 @@ test('getSearchQuery when highlight is true', () => {
},
},
},
{ $project: { highlights: { $meta: 'searchHighlights' } } },
{ $sort: { data: -1 } },
{ $facet: { hits: [{ $limit: 10 }], total: [{ $count: 'count' }] } },
];
// Snapshot demo
expect(result).toStrictEqual(expected);
});

test('getSearchQuery when highlight is true and performing wildcard highlight', () => {
const result = getSearchQuery(
test('getSearchOrSuggestionQuery when highlight is true and performing wildcard highlight', () => {
const result = getSearchOrSuggestionQuery(
{
value: 'Apart',
dataField: 'data',
Expand Down Expand Up @@ -545,7 +544,6 @@ test('getSearchQuery when highlight is true and performing wildcard highlight',
},
},
},
{ $project: { highlights: { $meta: 'searchHighlights' } } },
{ $sort: { data: -1 } },
{ $facet: { hits: [{ $limit: 10 }], total: [{ $count: 'count' }] } },
];
Expand Down
Loading