Skip to content
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
14,465 changes: 8,063 additions & 6,402 deletions dist/typesense-instantsearch-adapter.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense-instantsearch-adapter.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense-instantsearch-adapter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense-instantsearch-adapter.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ interface BaseAdapterOptions {
collectionSpecificFilterByOptions?: object;
sortByOptions?: object;
collectionSpecificSortByOptions?: object;
useExcludeForUnboundNumericRange?: boolean;
}

interface CollectionSearchParameters {
Expand Down
4 changes: 3 additions & 1 deletion lib/Configuration.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Configuration.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions lib/SearchRequestAdapter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/SearchRequestAdapter.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class Configuration {
this.collectionSpecificFacetByOptions = options.collectionSpecificFacetByOptions ?? {};
this.collectionSpecificFilterByOptions = options.collectionSpecificFilterByOptions ?? {};
this.collectionSpecificSortByOptions = options.collectionSpecificSortByOptions ?? {};
this.useExcludeForUnboundNumericRange = options.useExcludeForUnboundNumericRange ?? false;
}

validate() {
Expand Down
9 changes: 7 additions & 2 deletions src/SearchRequestAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,16 @@ export class SearchRequestAdapter {
});

// Transform that to:
// "field1:=[634..289] && field2:<=5 && field3:>=3"
// "field1:=[634..289] && field2:<=5 && field3:>=3"
// option to exclude unbound ranges
const adaptedFilters = [];
Object.keys(filtersHash).forEach((field) => {
if (filtersHash[field]["<="] != null && filtersHash[field][">="] != null) {
adaptedFilters.push(`${field}:=[${filtersHash[field][">="]}..${filtersHash[field]["<="]}]`);
if (this.configuration.useExcludeForUnboundNumericRange && parseInt(filtersHash[field][">="]) > parseInt(filtersHash[field]["<="])) {
adaptedFilters.push(`${field}:!=[${filtersHash[field]["<="]}..${filtersHash[field][">="]}]`);
} else {
adaptedFilters.push(`${field}:=[${filtersHash[field][">="]}..${filtersHash[field]["<="]}]`);
}
} else if (filtersHash[field]["<="] != null) {
adaptedFilters.push(`${field}:<=${filtersHash[field]["<="]}`);
} else if (filtersHash[field][">="] != null) {
Expand Down