File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { ElasticSearchDynamicQuery } = require ( 'elasticsearch-dynamic-query' ) ;
2
+
3
+ function example1 ( ) {
4
+ const command = {
5
+ title : {
6
+ type : 'TEXT' ,
7
+ conditions : {
8
+ $eq : title
9
+ }
10
+ }
11
+ }
12
+
13
+ const builder = new ElasticSearchDynamicQuery ( command ) ;
14
+ const query = builder . compoundQuery ( ) . build ( ) ;
15
+ console . log ( query ) ;
16
+ // bool: {
17
+ // must: [
18
+ // {
19
+ // match: {
20
+ // title: title
21
+ // }
22
+ // }
23
+ // ]
24
+ // }
25
+ }
26
+
27
+ function example2 ( ) {
28
+ const releaseYear = 2022 ;
29
+
30
+ const command = {
31
+ release_year : {
32
+ type : DataTypeEnum . NUMBER ,
33
+ conditions : {
34
+ $eq : releaseYear
35
+ }
36
+ }
37
+ }
38
+
39
+ const builder = new ElasticSearchDynamicQuery ( command ) ;
40
+ const query = builder . compoundQuery ( ) . build ( ) ;
41
+ console . log ( query ) ;
42
+ // bool: {
43
+ // must: [
44
+ // {
45
+ // term: {
46
+ // release_year: releaseYear
47
+ // }
48
+ // }
49
+ // ]
50
+ // }
51
+ }
You can’t perform that action at this time.
0 commit comments