Skip to content

Commit 4d880c1

Browse files
add lexile to solr (#10573)
* add lexile to solr & search --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5703300 commit 4d880c1

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

conf/solr/conf/managed-schema.xml

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@
161161
<field name="isbn" type="string" multiValued="true"/>
162162
<field name="ebook_access" type="ebookAccessLevel" multiValued="false"/>
163163

164+
<!-- Reading Levels -->
165+
<field name="lexile" type="pint" multiValued="true"/>
166+
164167
<!-- Classifications -->
165168
<field name="lcc" type="string" multiValued="true" />
166169
<field name="lcc_sort" type="string" stored="false" /> <!-- Need non-multiValued for sorting -->

openlibrary/plugins/worksearch/schemes/works.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class WorkSearchScheme(SearchScheme):
5555
"by_statement",
5656
"publish_date",
5757
"lccn",
58+
"lexile",
5859
"ia",
5960
"oclc",
6061
"isbn",

openlibrary/solr/solr_types.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SolrDocument(TypedDict):
3434
oclc: Optional[list[str]]
3535
isbn: Optional[list[str]]
3636
ebook_access: Optional[Literal['no_ebook', 'unclassified', 'printdisabled', 'borrowable', 'public']]
37+
lexile: Optional[list[int]]
3738
lcc: Optional[list[str]]
3839
lcc_sort: Optional[str]
3940
ddc: Optional[list[str]]

openlibrary/solr/updater/edition.py

+7
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ def cover_i(self) -> int | None:
144144
None,
145145
)
146146

147+
@property
148+
def lexile(self) -> int | None:
149+
try:
150+
return int(self._edition.get('lexile', None)) or None
151+
except (TypeError, ValueError):
152+
return None
153+
147154
@property
148155
def language(self) -> list[str]:
149156
"""Gets the 3 letter language codes (eg ['ger', 'fre'])"""

openlibrary/solr/updater/work.py

+4
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ def number_of_pages_median(self) -> int | None:
379379
else:
380380
return None
381381

382+
@property
383+
def lexile(self) -> set[int]:
384+
return {lex for e in self._solr_editions if (lex := e.lexile) is not None}
385+
382386
@property
383387
def editions(self) -> list[SolrDocument]:
384388
return [ed.build() for ed in self._solr_editions]

0 commit comments

Comments
 (0)