Replies: 2 comments 4 replies
-
I think the answer is here |
Beta Was this translation helpful? Give feedback.
0 replies
-
const algoliasearch = require("algoliasearch");
const algoliasearchHelper = require("algoliasearch-helper");
const requestBuilder = require("algoliasearch-helper/src/requestBuilder");
const client = algoliasearch("YourApplicationID", "YourSearchOnlyAPIKey");
const index = client.initIndex("YourIndexName");
const searchState = {
range: {
price: {
min: 20,
max: 3000,
},
},
refinementList: {
fruits: ["lemon", "orange"],
},
menu: {
brands: "Sony",
},
query: "ora",
page: 2,
};
const helper = algoliasearchHelper(client, index.indexName, {
disjunctiveFacets: ["fruits"],
facets: ["brands"],
hitsPerPage: 10,
page: searchState.page,
numericFilters: [`price >= ${searchState.range.price.min}`, `price <= ${searchState.range.price.max}`],
query: searchState.query,
});
if (searchState.refinementList && searchState.refinementList.fruits) {
helper.addDisjunctiveFacetRefinement("fruits", searchState.refinementList.fruits);
}
if (searchState.menu && searchState.menu.brands) {
helper.addFacetRefinement("brands", searchState.menu.brands);
}
const request = helper.state.getQueryParams({});
console.log(request);
const queries = requestBuilder._getQueries(index, helper.state);
console.log(queries); |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
hadminh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What function converts searchState to http_requests?
Beta Was this translation helpful? Give feedback.
All reactions