Skip to content

Commit 3c223e4

Browse files
committed
Fix parsing and query for filter matching
1 parent 2ade65b commit 3c223e4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

app/services/search_item_req.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ def filters
205205
# (type 2 will only be used for dates)
206206
filters = fields.map {|f| f.split(@@filter_separator, 3) }
207207
filters.each do |filter|
208-
# NESTED matching
208+
# filter aggregation with nesting
209209
if filter[0].include?("[")
210-
options = JSON.parse(f)
211-
original = options[1]
210+
original = filter[0]
212211
facet = original.split("[")[0]
213212
path = facet.split(".").first
214213
condition = original[/(?<=\[).+?(?=\])/]
@@ -217,17 +216,14 @@ def filters
217216
# this is a nested field and must be treated differently
218217
nested = {
219218
"nested" => {
220-
221219
"path" => path,
222220
"query" => {
223221
"bool" => {
224222
"must" => {
225-
"terms" => {
223+
"term" => {
226224
# "person.name" => "oliver wendell holmes"
227225
# Remove CR's added by hidden input field values with returns
228-
facet => filter[1].gsub(/\r/, ""),
229-
# "person.role" => "judge"
230-
subject => predicate
226+
facet => filter[1].gsub(/\r/, "")
231227
}
232228
}
233229
}

0 commit comments

Comments
 (0)