industrial-model 1.1.4__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,6 +59,7 @@ class CogniteAdapter:
59
59
  properties=search_query.query_properties,
60
60
  limit=search_query.limit,
61
61
  sort=search_query.sort,
62
+ operator=search_query.operator or "OR",
62
63
  )
63
64
 
64
65
  return self._result_mapper.nodes_to_dict(data)
@@ -4,7 +4,7 @@ import cognite.client.data_classes.filters as filters
4
4
  from cognite.client.data_classes.data_modeling import InstanceSort, View
5
5
 
6
6
  from industrial_model.models import TViewInstance
7
- from industrial_model.statements import SearchStatement
7
+ from industrial_model.statements import SearchOperationTypes, SearchStatement
8
8
 
9
9
  from .filter_mapper import (
10
10
  FilterMapper,
@@ -21,6 +21,7 @@ class SearchQuery:
21
21
  query_properties: list[str] | None
22
22
  limit: int
23
23
  sort: list[InstanceSort]
24
+ operator: SearchOperationTypes | None
24
25
 
25
26
 
26
27
  class SearchMapper:
@@ -47,4 +48,5 @@ class SearchMapper:
47
48
  query_properties=statement_values.query_properties,
48
49
  limit=statement_values.limit,
49
50
  sort=sort_clauses,
51
+ operator=statement_values.search_operator,
50
52
  )
@@ -4,6 +4,7 @@ from industrial_model.models import RootModel, TAggregatedViewInstance, TViewIns
4
4
  from industrial_model.statements import (
5
5
  AggregateTypes,
6
6
  AggregationStatement,
7
+ SearchOperationTypes,
7
8
  SearchStatement,
8
9
  Statement,
9
10
  aggregate,
@@ -37,6 +38,7 @@ class BasePaginatedQuery(BaseQuery):
37
38
  class BaseSearchQuery(RootModel):
38
39
  query: str | None = None
39
40
  query_properties: list[Any] | None = None
41
+ query_operator: SearchOperationTypes | None = None
40
42
  limit: int = 1000
41
43
 
42
44
  def to_statement(
@@ -45,7 +47,11 @@ class BaseSearchQuery(RootModel):
45
47
  statement = search(entity)
46
48
  _set_base_statement_params(self, statement)
47
49
  if self.query:
48
- statement.query_by(self.query, self.query_properties)
50
+ statement.query_by(
51
+ self.query,
52
+ self.query_properties,
53
+ self.query_operator,
54
+ )
49
55
  statement.limit(self.limit)
50
56
 
51
57
  return statement
@@ -16,6 +16,7 @@ from .expressions import (
16
16
 
17
17
  T = TypeVar("T")
18
18
  AggregateTypes = Literal["count", "avg", "min", "max", "sum"]
19
+ SearchOperationTypes = Literal["OR", "AND"]
19
20
 
20
21
 
21
22
  def _create_column(property: str | Column | Any) -> Column:
@@ -36,6 +37,7 @@ class BaseStatementValues:
36
37
 
37
38
  query: str | None = field(init=False, default=None)
38
39
  query_properties: list[str] | None = field(init=False, default=None)
40
+ search_operator: SearchOperationTypes | None = field(init=False, default=None)
39
41
 
40
42
 
41
43
  @dataclass
@@ -106,6 +108,7 @@ class SearchStatement(BaseStatement[T]):
106
108
  self,
107
109
  query: str,
108
110
  query_properties: list[Column] | list[str] | list[Any] | None = None,
111
+ operation: SearchOperationTypes | None = None,
109
112
  ) -> Self:
110
113
  self._values.query = query
111
114
  self._values.query_properties = (
@@ -120,6 +123,7 @@ class SearchStatement(BaseStatement[T]):
120
123
  if query_properties
121
124
  else None
122
125
  )
126
+ self._values.search_operator = operation
123
127
  return self
124
128
 
125
129
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 1.1.4
3
+ Version: 1.2.0
4
4
  Summary: Industrial Model ORM
5
5
  Project-URL: Homepage, https://github.com/lucasrosaalves/industrial-model
6
6
  Project-URL: Source, https://github.com/lucasrosaalves/industrial-model
@@ -244,7 +244,11 @@ from industrial_model import search
244
244
  search_statement = (
245
245
  search(CogniteAsset)
246
246
  .where(col(CogniteAsset.aliases).contains_any_(["my_alias"]))
247
- .query_by("my fuzzy name", [CogniteAsset.name])
247
+ .query_by(
248
+ query="my fuzzy name",
249
+ query_properties=[CogniteAsset.name],
250
+ operator="AND",
251
+ )
248
252
  )
249
253
 
250
254
  search_result = engine.search(search_statement)
@@ -3,14 +3,14 @@ industrial_model/config.py,sha256=fiwW-54fgCBY6ciFlRqeCBCNUvY41D-xuv8rCH7Ok54,29
3
3
  industrial_model/constants.py,sha256=MO85Wk05LHrpfbS4zml1hneJNFxht2oa3KFAKXw92qo,450
4
4
  industrial_model/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  industrial_model/utils.py,sha256=oh4AxwxXaWgIC2uolkCbvkgo0ququHB6yAPVIXy45Ts,663
6
- industrial_model/cognite_adapters/__init__.py,sha256=y8vCi2HdjDDkjqPt9y9LTpWu4ZFtc-65re70aHmc-ho,6497
6
+ industrial_model/cognite_adapters/__init__.py,sha256=RQPPTV13gr7T3jopWvKarvK-NcB21hpOHn1ZEzh2gUA,6549
7
7
  industrial_model/cognite_adapters/aggregation_mapper.py,sha256=CYbOR7Eh447PEwCtPKFCHYh3-K6akwLTJdQ-oeSYvKo,2599
8
8
  industrial_model/cognite_adapters/filter_mapper.py,sha256=eSrEYdEKZHQuJ98gblBYy1qCe5VYpq3fjLSUg8614fk,5261
9
9
  industrial_model/cognite_adapters/models.py,sha256=2j2IS01uPkQEp9WdVk8seYzEqGcDdWFnpzXhusHB2zk,945
10
10
  industrial_model/cognite_adapters/optimizer.py,sha256=-iorsO-yOe8wuMNBMsV1KjAmC3-Yiewte4JKnyQyHOo,2345
11
11
  industrial_model/cognite_adapters/query_mapper.py,sha256=tpRdrEW6i0NKy5h6bYrIIP96nanPSokK-s5-1d0PES8,6597
12
12
  industrial_model/cognite_adapters/query_result_mapper.py,sha256=0X8Fg2kLwWZuylVtU6hB_n7x3VOl-rdfOZWOn7e_QCs,10238
13
- industrial_model/cognite_adapters/search_mapper.py,sha256=zRe5FgucTWHX2VVbh3iLmzM7FmUAFhJG5t42gXnnJrE,1587
13
+ industrial_model/cognite_adapters/search_mapper.py,sha256=5RCoQSsNxnAzU-oGD1SI3MAxcx1lOwgBQNVQnamGDwA,1706
14
14
  industrial_model/cognite_adapters/sort_mapper.py,sha256=EQ2Xpfdet8jN6EK0rEZ3IA8L7sPXWVX1MA9kQg4LdXs,1083
15
15
  industrial_model/cognite_adapters/upsert_mapper.py,sha256=iHt3gOEruFkZmg7KdynVPdRA7VZbuKhjAST0uFPb5rM,5125
16
16
  industrial_model/cognite_adapters/utils.py,sha256=EFcycPxu7YCjH-GyyLzl7nylm1Aii5dqQy27s3Pn6gs,4842
@@ -25,12 +25,12 @@ industrial_model/models/entities.py,sha256=-Jf7bNCijbS3_wZohlog3bRsAkXvkUeAQW9Da
25
25
  industrial_model/models/schemas.py,sha256=EoLK9GYdS-0DQ98myTP3wOU9YpWIJOfDSLOYZUy3xEY,4559
26
26
  industrial_model/models/utils.py,sha256=MFS8OyCfh4cYPY_R66-mUaCauQfQy0vd558Rw0tiGDc,1786
27
27
  industrial_model/queries/__init__.py,sha256=lA83zOxMRgBgkseWJgK9kCr1vD8D8iSWs9NGGRnoYKk,355
28
- industrial_model/queries/models.py,sha256=VK69c4L0b0miPrKvOQBB8A01SPxZXYThrquv6gw5OGY,2544
28
+ industrial_model/queries/models.py,sha256=bXQL3udhAf2Yssi00O3WycgACKrKifR65dh7CR8W_48,2709
29
29
  industrial_model/queries/params.py,sha256=50qY5BO5onLsXorhcv-7qCKhJaMO94UzhKLCmZKY55s,1667
30
30
  industrial_model/queries/utils.py,sha256=uP6PLh9IVHDK6J8x444zHWPmyV4PkxdLO-PMc6qWItc,1505
31
- industrial_model/statements/__init__.py,sha256=3Et9PM7AMbIS7Fh9051Q0u3qUpX6588d1yuNrvdd4wI,5429
31
+ industrial_model/statements/__init__.py,sha256=xazAVHvN8HKsWcXR2Hp1aGxd59stg13JXO6tgpJnsC4,5660
32
32
  industrial_model/statements/expressions.py,sha256=4ZZOcZroI5-4xRw4PXIRlufi0ARndE5zSbbxLDpR2Ec,4816
33
- industrial_model-1.1.4.dist-info/METADATA,sha256=hEnX14-j55IQXz3gf5C_R4p_dWVFlmiJLgF12XznkLw,7700
34
- industrial_model-1.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- industrial_model-1.1.4.dist-info/licenses/LICENSE,sha256=BCHCZ1Qo7m4YvAEIQqtVBI3NebFJdZ8_7m_cxInIlN0,4934
36
- industrial_model-1.1.4.dist-info/RECORD,,
33
+ industrial_model-1.2.0.dist-info/METADATA,sha256=mUD0K0gPDpPSf-yPi6rhnx_vfkmCl1h6h701nqotsuw,7770
34
+ industrial_model-1.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ industrial_model-1.2.0.dist-info/licenses/LICENSE,sha256=BCHCZ1Qo7m4YvAEIQqtVBI3NebFJdZ8_7m_cxInIlN0,4934
36
+ industrial_model-1.2.0.dist-info/RECORD,,