Changeset View
Changeset View
Standalone View
Standalone View
swh/search/elasticsearch.py
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | def origin_search( | ||||
""" | """ | ||||
query_clauses = [] # type: List[Dict[str, Any]] | query_clauses = [] # type: List[Dict[str, Any]] | ||||
if url_pattern: | if url_pattern: | ||||
query_clauses.append({ | query_clauses.append({ | ||||
'multi_match': { | 'multi_match': { | ||||
'query': url_pattern, | 'query': url_pattern, | ||||
'type': 'bool_prefix', | 'type': 'bool_prefix', | ||||
'operator': 'and', | |||||
'fields': [ | 'fields': [ | ||||
'url.as_you_type', | 'url.as_you_type', | ||||
'url.as_you_type._2gram', | 'url.as_you_type._2gram', | ||||
'url.as_you_type._3gram', | 'url.as_you_type._3gram', | ||||
] | ] | ||||
} | } | ||||
}) | }) | ||||
if metadata_pattern: | if metadata_pattern: | ||||
query_clauses.append({ | query_clauses.append({ | ||||
'nested': { | 'nested': { | ||||
'path': 'intrinsic_metadata', | 'path': 'intrinsic_metadata', | ||||
'query': { | 'query': { | ||||
'multi_match': { | 'multi_match': { | ||||
'query': metadata_pattern, | 'query': metadata_pattern, | ||||
'operator': 'and', | |||||
'fields': ['intrinsic_metadata.*'] | 'fields': ['intrinsic_metadata.*'] | ||||
} | } | ||||
}, | }, | ||||
} | } | ||||
}) | }) | ||||
if not query_clauses: | if not query_clauses: | ||||
raise ValueError( | raise ValueError( | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |