Skip to content

Commit

Permalink
Add fuzzy auto (#1359)
Browse files Browse the repository at this point in the history
* Add fuzzy auto

* Fix tests to fuzzy=auto
  • Loading branch information
vhaalmeida authored Jun 10, 2022
1 parent db07e1f commit 2bc768d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions packages/api/mocks/AllProductsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const AllProductsQueryFirst5 = `query AllProducts {

export const productSearchPage1Count5Fetch = {
info:
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=0&locale=en-US&hideUnavailableItems=false',
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false',
init: undefined,
result: {
products: [
Expand Down Expand Up @@ -812,44 +812,44 @@ export const productSearchPage1Count5Fetch = {
correction: {
misspelled: true,
},
fuzzy: '0',
fuzzy: 'auto',
operator: 'and',
translated: false,
pagination: {
count: 50,
current: {
index: 1,
proxyUrl:
'search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&operator=and',
},
before: [],
after: [
{
index: 2,
proxyUrl:
'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 3,
proxyUrl:
'search/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 4,
proxyUrl:
'search/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 5,
proxyUrl:
'search/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=auto&operator=and',
},
],
perPage: 5,
next: {
index: 2,
proxyUrl:
'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and',
},
previous: {
index: 0,
Expand All @@ -860,7 +860,7 @@ export const productSearchPage1Count5Fetch = {
last: {
index: 50,
proxyUrl:
'search/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=auto&operator=and',
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/api/mocks/ProductQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const ProductByIdQuery = `query ProductQuery {

export const productSearchFetch = {
info:
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&fuzzy=0&locale=en-US&hideUnavailableItems=false',
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false',
init: undefined,
result: {
products: [
Expand Down Expand Up @@ -226,15 +226,15 @@ export const productSearchFetch = {
correction: {
misspelled: true,
},
fuzzy: '0',
fuzzy: 'auto',
operator: 'and',
translated: false,
pagination: {
count: 1,
current: {
index: 1,
proxyUrl:
'search/trade-policy/1?page=1&count=1&query=sku:64953394&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=1&count=1&query=sku:64953394&sort=&fuzzy=auto&operator=and',
},
before: [],
after: [],
Expand Down
20 changes: 10 additions & 10 deletions packages/api/mocks/SearchQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const SearchQueryFirst5Products = `query SearchQuery {

export const productSearchCategory1Fetch = {
info:
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=0&locale=en-US&hideUnavailableItems=false',
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false',
init: undefined,
result: {
products: [
Expand Down Expand Up @@ -1327,44 +1327,44 @@ export const productSearchCategory1Fetch = {
correction: {
misspelled: true,
},
fuzzy: '0',
fuzzy: 'auto',
operator: 'and',
translated: false,
pagination: {
count: 50,
current: {
index: 1,
proxyUrl:
'search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&operator=and',
},
before: [],
after: [
{
index: 2,
proxyUrl:
'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 3,
proxyUrl:
'search/category-1/office/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 4,
proxyUrl:
'search/category-1/office/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=auto&operator=and',
},
{
index: 5,
proxyUrl:
'search/category-1/office/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=auto&operator=and',
},
],
perPage: 5,
next: {
index: 2,
proxyUrl:
'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and',
},
previous: {
index: 0,
Expand All @@ -1375,15 +1375,15 @@ export const productSearchCategory1Fetch = {
last: {
index: 50,
proxyUrl:
'search/category-1/office/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=0&operator=and',
'search/category-1/office/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=auto&operator=and',
},
},
},
}

export const attributeSearchCategory1Fetch = {
info:
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=0&locale=en-US&hideUnavailableItems=false',
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false',
init: undefined,
result: {
facets: [
Expand Down
6 changes: 3 additions & 3 deletions packages/api/mocks/ValidateCartMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export const checkoutOrderFormCustomDataInvalidFetch = {

export const productSearchPage1Count1Fetch = {
info:
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&fuzzy=0&locale=en-US&hideUnavailableItems=false',
'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false',
init: undefined,
result: {
products: [
Expand Down Expand Up @@ -529,15 +529,15 @@ export const productSearchPage1Count1Fetch = {
correction: {
misspelled: true,
},
fuzzy: '0',
fuzzy: 'auto',
operator: 'and',
translated: false,
pagination: {
count: 1,
current: {
index: 1,
proxyUrl:
'search/trade-policy/1?page=1&count=1&query=sku:2737806&sort=&fuzzy=0&operator=and',
'search/trade-policy/1?page=1&count=1&query=sku:2737806&sort=&fuzzy=auto&operator=and',
},
before: [],
after: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/platforms/vtex/clients/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface SearchArgs {
type: 'product_search' | 'facets'
sort?: Sort
selectedFacets?: SelectedFacet[]
fuzzy?: '0' | '1'
fuzzy?: '0' | '1' | 'auto'
hideUnavailableItems?: boolean
}

Expand Down Expand Up @@ -97,7 +97,7 @@ export const IntelligentSearch = (
sort = '',
selectedFacets = [],
type,
fuzzy = '0',
fuzzy = 'auto',
}: SearchArgs): Promise<T> => {
const params = new URLSearchParams({
page: (page + 1).toString(),
Expand Down

1 comment on commit 2bc768d

@vercel
Copy link

@vercel vercel bot commented on 2bc768d Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.