File tree Expand file tree Collapse file tree 1 file changed +4
-37
lines changed Expand file tree Collapse file tree 1 file changed +4
-37
lines changed Original file line number Diff line number Diff line change @@ -122,53 +122,20 @@ impl SearchStore for ElasticsearchSearchStore {
122
122
"should" : filter_conditions,
123
123
"minimum_should_match" : 1
124
124
}
125
- } ,
126
- "runtime_mappings" : {
127
- "has_children" : {
128
- "type" : "boolean" ,
129
- "script" : {
130
- "source" : "def children = searchInternalByField('parent_id', doc['node_id'].value); emit(children.size() > 0);"
131
- }
132
- } ,
133
- "parent_title" : {
134
- "type" : "keyword" ,
135
- "script" : {
136
- "source" : "if (!doc['parent_id'].isEmpty()) { def parents = searchInternalByField('node_id', doc['parent_id'].value); if (parents.size() > 0) { emit(parents[0].title); } }"
137
- }
138
- }
139
- } ,
140
- "fields" : [ "*" , "has_children" , "parent_title" ] ,
141
- "_source" : true
125
+ }
142
126
} ) )
143
127
. send ( )
144
128
. await ?;
145
129
146
130
match response. status_code ( ) . is_success ( ) {
147
131
true => {
132
+ // get nodes from elasticsearch response in hits.hits
148
133
let response_body = response. json :: < serde_json:: Value > ( ) . await ?;
149
- let nodes: Vec < CoreContentNode > = response_body[ "hits" ] [ "hits" ]
134
+ let nodes: Vec < Node > = response_body[ "hits" ] [ "hits" ]
150
135
. as_array ( )
151
136
. unwrap ( )
152
137
. iter ( )
153
- . map ( |h| {
154
- let base = Node :: from ( h. get ( "_source" ) . unwrap ( ) . clone ( ) ) ;
155
- let has_children = h
156
- . get ( "fields" )
157
- . and_then ( |fields| fields. get ( "has_children" ) )
158
- . and_then ( |arr| arr. get ( 0 ) )
159
- . and_then ( |v| v. as_bool ( ) )
160
- . unwrap_or ( false ) ;
161
-
162
- let parent_title = h
163
- . get ( "fields" )
164
- . and_then ( |fields| fields. get ( "parent_title" ) )
165
- . and_then ( |arr| arr. get ( 0 ) )
166
- . and_then ( |v| v. as_str ( ) )
167
- . unwrap_or ( "" )
168
- . to_string ( ) ;
169
-
170
- CoreContentNode :: new ( base, has_children, parent_title)
171
- } )
138
+ . map ( |h| Node :: from ( h. get ( "_source" ) . unwrap ( ) . clone ( ) ) )
172
139
. collect ( ) ;
173
140
Ok ( nodes)
174
141
}
You can’t perform that action at this time.
0 commit comments