Changeset View
Changeset View
Standalone View
Standalone View
swh/search/translator.py
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | def _parse_filter(self, filter): | ||||
"lenient": True, | "lenient": True, | ||||
} | } | ||||
}, | }, | ||||
} | } | ||||
} | } | ||||
if category == "booleanFilter": | if category == "booleanFilter": | ||||
if name == "visited": | if name == "visited": | ||||
return {"term": {"has_visits": value == "true"}} | if value == "true": | ||||
return {"term": {"has_visits": True}} | |||||
else: | |||||
# non-visited origins will typically not have "has_visits" set | |||||
# at all | |||||
return { | |||||
"bool": { | |||||
"should": [ | |||||
{"term": {"has_visits": False}}, | |||||
{ | |||||
"bool": { | |||||
"must_not": {"exists": {"field": "has_visits"}} | |||||
} | |||||
}, | |||||
] | |||||
} | |||||
} | |||||
if category == "numericFilter": | if category == "numericFilter": | ||||
if name == "visits": | if name == "visits": | ||||
if op in ["=", "!="]: | if op in ["=", "!="]: | ||||
return { | return { | ||||
"bool": { | "bool": { | ||||
("must" if op == "=" else "must_not"): [ | ("must" if op == "=" else "must_not"): [ | ||||
{"range": {"nb_visits": {"gte": value, "lte": value}}} | {"range": {"nb_visits": {"gte": value, "lte": value}}} | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |