Browse Source

Just use _source instead of _source + fields

main
Dylan Baker 4 years ago
parent
commit
b29cf12916
1 changed files with 4 additions and 11 deletions
  1. 4
    11
      src/compiler.rs

+ 4
- 11
src/compiler.rs View File

29
 }
29
 }
30
 
30
 
31
 pub fn compile(expr: Select) -> Result<Query, CompilerError> {
31
 pub fn compile(expr: Select) -> Result<Query, CompilerError> {
32
-    let mut source = false;
33
     let field_names: Vec<Value> = expr
32
     let field_names: Vec<Value> = expr
34
         .fields
33
         .fields
35
         .iter()
34
         .iter()
36
         .map(|f| match f {
35
         .map(|f| match f {
37
-            Field::Star => {
38
-                source = true;
39
-                Value::String("*".to_string())
40
-            }
36
+            Field::Star => Value::String("*".to_string()),
41
             Field::Named(name) => Value::String(name.clone()),
37
             Field::Named(name) => Value::String(name.clone()),
42
         })
38
         })
43
         .collect();
39
         .collect();
44
 
40
 
45
     let body = json!({
41
     let body = json!({
46
         "query": { "match_all":{} },
42
         "query": { "match_all":{} },
47
-        "_source": source,
48
-        "fields": Value::Array(field_names)
43
+        "_source": Value::Array(field_names)
49
     });
44
     });
50
 
45
 
51
     Ok(Query::new(expr.source, body))
46
     Ok(Query::new(expr.source, body))
73
                     "query": {
68
                     "query": {
74
                         "match_all": {}
69
                         "match_all": {}
75
                     },
70
                     },
76
-                    "fields": ["*"],
77
-                    "_source": true
71
+                    "_source": ["*"]
78
                 })
72
                 })
79
             )
73
             )
80
         )
74
         )
90
                     "query": {
84
                     "query": {
91
                         "match_all": {}
85
                         "match_all": {}
92
                     },
86
                     },
93
-                    "fields": ["foo"],
94
-                    "_source": false
87
+                    "_source": ["foo"]
95
                 })
88
                 })
96
             )
89
             )
97
         )
90
         )

Loading…
Cancel
Save