Skip to content

Commit afc76c5

Browse files
committed
group results by document_id
1 parent a89ef04 commit afc76c5

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "salinic"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "Search abstraction layer"
55
authors = ["Eugen Ciur <[email protected]>"]
66
readme = "README.md"

salinic/backends/solr/index.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def __init__(self, client, schema):
1616
self.schema = schema
1717

1818
def search(self, sq: SearchQuery):
19+
"""
20+
21+
"""
1922
result = self.client.search(sq)
2023
if result['response']['numFound'] == 0:
2124
return []

salinic/backends/solr/schema_manager.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from typing import List, Tuple
33

4-
from salinic.field import Field, NumericField
4+
from salinic.field import Field, NumericField, StringField
55
from salinic.utils import first
66

77
from .types import CopyFieldDump, FieldDump, FieldType
@@ -109,6 +109,10 @@ def _normal_fields(self) -> List[Tuple[str, FieldDump]]:
109109

110110
if isinstance(field_instance, NumericField):
111111
_type = FieldType.pint
112+
elif isinstance(field_instance, StringField):
113+
_type = FieldType.string
114+
elif field_instance.group:
115+
_type = FieldType.text_gen_sort
112116
else:
113117
_type = FieldType.text_general
114118

salinic/backends/solr/types.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def to_dash(string: str) -> str:
1111

1212
class FieldType(str, Enum):
1313
text_general = 'text_general'
14+
text_gen_sort = 'text_gen_sort'
15+
string = 'string'
1416
pint = 'pint'
1517

1618

salinic/field.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class Field(NamedTuple):
99
default: any = None
1010
multi_value: bool = False
1111
multi_lang: bool = False
12+
# enables grouping by this field
13+
group: bool = False
1214

1315

1416
class KeywordField(Field):
@@ -23,6 +25,10 @@ class NumericField(Field):
2325
pass
2426

2527

28+
class StringField(Field):
29+
pass
30+
31+
2632
class IdField(Field):
2733
pass
2834

0 commit comments

Comments
 (0)