-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmethods_remove-filter.js.html
More file actions
112 lines (76 loc) · 5.07 KB
/
Copy pathmethods_remove-filter.js.html
File metadata and controls
112 lines (76 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>methods/remove-filter.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="EcomSearch.html">EcomSearch</a><ul class='methods'><li data-type='method'><a href="EcomSearch.html#fetch">fetch</a></li><li data-type='method'><a href="EcomSearch.html#getBrands">getBrands</a></li><li data-type='method'><a href="EcomSearch.html#getCategories">getCategories</a></li><li data-type='method'><a href="EcomSearch.html#getItems">getItems</a></li><li data-type='method'><a href="EcomSearch.html#getPriceRange">getPriceRange</a></li><li data-type='method'><a href="EcomSearch.html#getSpecs">getSpecs</a></li><li data-type='method'><a href="EcomSearch.html#getTermSuggestions">getTermSuggestions</a></li><li data-type='method'><a href="EcomSearch.html#getTotalCount">getTotalCount</a></li><li data-type='method'><a href="EcomSearch.html#mergeFilter">mergeFilter</a></li><li data-type='method'><a href="EcomSearch.html#removeFilter">removeFilter</a></li><li data-type='method'><a href="EcomSearch.html#reset">reset</a></li><li data-type='method'><a href="EcomSearch.html#setBrandIds">setBrandIds</a></li><li data-type='method'><a href="EcomSearch.html#setBrandNames">setBrandNames</a></li><li data-type='method'><a href="EcomSearch.html#setCategoryIds">setCategoryIds</a></li><li data-type='method'><a href="EcomSearch.html#setCategoryNames">setCategoryNames</a></li><li data-type='method'><a href="EcomSearch.html#setPageNumber">setPageNumber</a></li><li data-type='method'><a href="EcomSearch.html#setPageSize">setPageSize</a></li><li data-type='method'><a href="EcomSearch.html#setPriceRange">setPriceRange</a></li><li data-type='method'><a href="EcomSearch.html#setProductIds">setProductIds</a></li><li data-type='method'><a href="EcomSearch.html#setSearchTerm">setSearchTerm</a></li><li data-type='method'><a href="EcomSearch.html#setSkus">setSkus</a></li><li data-type='method'><a href="EcomSearch.html#setSortOrder">setSortOrder</a></li><li data-type='method'><a href="EcomSearch.html#setSpec">setSpec</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-@ecomplus_search-engine.html">@ecomplus/search-engine</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addGlobalFilter">addGlobalFilter</a></li><li><a href="global.html#setSalesChannel">setSalesChannel</a></li><li><a href="global.html#setWarehouse">setWarehouse</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">methods/remove-filter.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>export default (self, field, occur = 'filter') => {
// remove filter for current product field
const filters = self.dsl.query && self.dsl.query.bool && self.dsl.query.bool[occur]
if (Array.isArray(filters)) {
for (let i = 0; i < filters.length; i++) {
const filter = filters[i]
if ((filter.nested && filter.nested.path === field) || filter[Object.keys(filter)[0]][field]) {
// remove filters array element
filters.splice(i, 1)
break
}
}
}
return self
}
/**
* @method
* @name EcomSearch#removeFilter
* @description Remove a filter object on current
* Query DSL filters list for next search request.
*
* @param {string} field - A valid
* [item field]{@link https://developers.e-com.plus/docs/api/#/search/items/items}
* with dot notation for nested properties
* @param {string} [occur='filter'] - Occurrence type for
* [boolean query]{@link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html}
* @returns {self}
*
* @example
// Remove filter by brand IDs and all specification filters
search.removeFilter('brands._id').removeFilter('specs')
* @example
// Remove filter by category names and run seach request
search.removeFilter('categories.name').fetch()
*/
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Feb 22 2023 20:40:42 GMT-0300 (Brasilia Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>