Skip to content

Commit 11c8194

Browse files
authored
Merge pull request #34 from cedadev/conditional_method
Conditional method
2 parents bb4494e + 294d91f commit 11c8194

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "Extraction Methods"
1414
copyright = "2025, Rhys Evans"
1515
author = "Rhys Evans"
16-
release = "1.1.2"
16+
release = "1.1.3"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extraction_methods/plugins/assets/backends/elasticsearch.py

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -86,41 +86,15 @@ def run(self, body: dict[str, Any]) -> Iterator[dict[str, Any]]:
8686

8787
es = Elasticsearch_client(**self.input.client_kwargs)
8888

89-
es_body = {
90-
"query": {
91-
"bool": {
92-
"must": [
93-
{
94-
"regexp": {
95-
f"{self.input.search_field}.keyword": {
96-
"value": self.input.regex,
97-
}
98-
}
99-
},
100-
{"exists": {"field": "md5"}},
101-
],
102-
"must_not": [{"exists": {"field": "removed"}}],
103-
},
104-
},
105-
"_source": [self.input.href_term, self.input.search_field]
106-
+ [extra_field.key for extra_field in self.input.extra_fields],
107-
}
108-
10989
# Run search
11090
result = es.search(
11191
index=self.input.index,
112-
body=es_body,
92+
body=self.input.body,
11393
timeout=f"{self.input.request_timeout}s",
11494
)
11595

11696
for hit in result["hits"]["hits"]:
11797
source = hit["_source"]
118-
asset = {
119-
"href": source[self.input.href_term],
120-
}
121-
122-
for field in self.input.extra_fields:
123-
if value := source.get(field.key):
124-
asset[field.output_key] = value
98+
source["href"] = source.pop(self.input.href_term)
12599

126-
yield asset
100+
yield source

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "extraction-methods"
3-
version = "1.1.2"
3+
version = "1.1.3"
44
description = "Methods to enable the extraction of metadata"
55
authors = [
66
{"name" = "rhysrevans3", "email" = "<[email protected]>"},

0 commit comments

Comments
 (0)