Skip to content

Commit f51c664

Browse files
committed
feat: Refactor authorities searchable indices for improved maintainability and readability
1 parent 0ac60a1 commit f51c664

2 files changed

Lines changed: 160 additions & 70 deletions

File tree

src/features/search/core/constants/ldAuthoritiesIndices.constants.ts

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,34 @@ import { SearchableIndex, SearchableIndexQuerySelector } from '@/common/constant
77
* - Type-based indices (person, organization, ...) constrain by `type` and match the label.
88
* The `sortby` clause is appended by the request builder, not baked into the templates.
99
*/
10+
11+
const typeLabelEntry = (type: string) => ({
12+
[SearchableIndexQuerySelector.Query]: `(type=="${type}" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
13+
});
14+
1015
export const LD_AUTHORITIES_SEARCHABLE_INDICES_MAP: SearchableIndicesMap = {
1116
[SearchSegment.Search]: {
1217
[SearchableIndex.Keyword]: {
1318
[SearchableIndexQuerySelector.Query]: `(keyword all "${SEARCH_QUERY_VALUE_PARAM}")`,
1419
},
20+
// Identifier intentionally uses the same lccn query as LCCN
1521
[SearchableIndex.Identifier]: {
1622
[SearchableIndexQuerySelector.Query]: `(lccn all "${SEARCH_QUERY_VALUE_PARAM}")`,
1723
},
1824
[SearchableIndex.LCCN]: {
1925
[SearchableIndexQuerySelector.Query]: `(lccn all "${SEARCH_QUERY_VALUE_PARAM}")`,
2026
},
21-
[SearchableIndex.Concept]: {
22-
[SearchableIndexQuerySelector.Query]: `(type=="concept" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
23-
},
24-
[SearchableIndex.Family]: {
25-
[SearchableIndexQuerySelector.Query]: `(type=="family" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
26-
},
27-
[SearchableIndex.Form]: {
28-
[SearchableIndexQuerySelector.Query]: `(type=="form" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
29-
},
30-
[SearchableIndex.Jurisdiction]: {
31-
[SearchableIndexQuerySelector.Query]: `(type=="jurisdiction" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
32-
},
33-
[SearchableIndex.Meeting]: {
34-
[SearchableIndexQuerySelector.Query]: `(type=="meeting" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
35-
},
36-
[SearchableIndex.Organization]: {
37-
[SearchableIndexQuerySelector.Query]: `(type=="organization" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
38-
},
39-
[SearchableIndex.Person]: {
40-
[SearchableIndexQuerySelector.Query]: `(type=="person" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
41-
},
42-
[SearchableIndex.Place]: {
43-
[SearchableIndexQuerySelector.Query]: `(type=="place" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
44-
},
45-
[SearchableIndex.Subject]: {
46-
[SearchableIndexQuerySelector.Query]: `(type=="concept" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
47-
},
48-
[SearchableIndex.Temporal]: {
49-
[SearchableIndexQuerySelector.Query]: `(type=="temporal" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
50-
},
51-
[SearchableIndex.Topic]: {
52-
[SearchableIndexQuerySelector.Query]: `(type=="topic" and label all "${SEARCH_QUERY_VALUE_PARAM}")`,
53-
},
27+
[SearchableIndex.Concept]: typeLabelEntry('concept'),
28+
[SearchableIndex.Family]: typeLabelEntry('family'),
29+
[SearchableIndex.Form]: typeLabelEntry('form'),
30+
[SearchableIndex.Jurisdiction]: typeLabelEntry('jurisdiction'),
31+
[SearchableIndex.Meeting]: typeLabelEntry('meeting'),
32+
[SearchableIndex.Organization]: typeLabelEntry('organization'),
33+
[SearchableIndex.Person]: typeLabelEntry('person'),
34+
[SearchableIndex.Place]: typeLabelEntry('place'),
35+
[SearchableIndex.Subject]: typeLabelEntry('subject'),
36+
[SearchableIndex.Temporal]: typeLabelEntry('temporal'),
37+
[SearchableIndex.Topic]: typeLabelEntry('topic'),
5438
},
5539
[SearchSegment.Browse]: {},
5640
};

src/features/search/ui/config/authoritiesUI.config.ts

Lines changed: 143 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,81 @@ export const authoritiesUIConfig: SearchTypeUIConfig = {
2727
},
2828
// Base-level combined SearchBy list: all options across all sources
2929
searchableIndices: [
30-
{ labelId: 'ld.keyword', value: SearchableIndex.Keyword },
31-
{ labelId: 'ld.identifierAll', value: SearchableIndex.Identifier },
32-
{ labelId: 'ld.lccn', value: SearchableIndex.LCCN },
33-
{ labelId: 'ld.concept', value: SearchableIndex.Concept },
34-
{ labelId: 'ld.family', value: SearchableIndex.Family },
35-
{ labelId: 'ld.form', value: SearchableIndex.Form },
36-
{ labelId: 'ld.jurisdiction', value: SearchableIndex.Jurisdiction },
37-
{ labelId: 'ld.meeting', value: SearchableIndex.Meeting },
38-
{ labelId: 'ld.organization', value: SearchableIndex.Organization },
39-
{ labelId: 'ld.person', value: SearchableIndex.Person },
40-
{ labelId: 'ld.place', value: SearchableIndex.Place },
41-
{ labelId: 'ld.subject', value: SearchableIndex.Subject },
42-
{ labelId: 'ld.childrensSubjectHeading', value: SearchableIndex.ChildrenSubjectHeading },
43-
{ labelId: 'ld.temporal', value: SearchableIndex.Temporal },
44-
{ labelId: 'ld.topic', value: SearchableIndex.Topic },
45-
{ labelId: 'ld.uniformTitle', value: SearchableIndex.UniformTitle },
46-
{ labelId: 'ld.nameTitle', value: SearchableIndex.NameTitle },
30+
{
31+
labelId: 'ld.keyword',
32+
value: SearchableIndex.Keyword,
33+
},
34+
{
35+
labelId: 'ld.identifierAll',
36+
value: SearchableIndex.Identifier,
37+
},
38+
{
39+
labelId: 'ld.lccn',
40+
value: SearchableIndex.LCCN,
41+
},
42+
{
43+
labelId: 'ld.concept',
44+
value: SearchableIndex.Concept,
45+
},
46+
{
47+
labelId: 'ld.family',
48+
value: SearchableIndex.Family,
49+
},
50+
{
51+
labelId: 'ld.form',
52+
value: SearchableIndex.Form,
53+
},
54+
{
55+
labelId: 'ld.jurisdiction',
56+
value: SearchableIndex.Jurisdiction,
57+
},
58+
{
59+
labelId: 'ld.meeting',
60+
value: SearchableIndex.Meeting,
61+
},
62+
{
63+
labelId: 'ld.organization',
64+
value: SearchableIndex.Organization,
65+
},
66+
{
67+
labelId: 'ld.person',
68+
value: SearchableIndex.Person,
69+
},
70+
{
71+
labelId: 'ld.place',
72+
value: SearchableIndex.Place,
73+
},
74+
{
75+
labelId: 'ld.subject',
76+
value: SearchableIndex.Subject,
77+
},
78+
{
79+
labelId: 'ld.childrensSubjectHeading',
80+
value: SearchableIndex.ChildrenSubjectHeading,
81+
},
82+
{
83+
labelId: 'ld.temporal',
84+
value: SearchableIndex.Temporal,
85+
},
86+
{
87+
labelId: 'ld.topic',
88+
value: SearchableIndex.Topic,
89+
},
90+
{
91+
labelId: 'ld.uniformTitle',
92+
value: SearchableIndex.UniformTitle,
93+
},
94+
{
95+
labelId: 'ld.nameTitle',
96+
value: SearchableIndex.NameTitle,
97+
},
4798
],
4899

49100
// Segment-specific overrides for complex-lookup (Edit page modals).
50101
// These override the base config and are NOT used by the Search page.
51102
segments: {
52103
search: {
53-
limit: 100,
104+
limit: 100, // UI shows all 100 results per page
54105
features: {
55106
hasSegments: true,
56107
hasSourceToggle: false,
@@ -62,24 +113,58 @@ export const authoritiesUIConfig: SearchTypeUIConfig = {
62113
isVisibleEmptySearchPlaceholder: true,
63114
},
64115
searchableIndices: [
65-
{ labelId: 'ld.keyword', value: SearchableIndex.Keyword },
66-
{ labelId: 'ld.identifierAll', value: SearchableIndex.Identifier },
67-
{ labelId: 'ld.lccn', value: SearchableIndex.LCCN },
68-
{ labelId: 'ld.personalName', value: SearchableIndex.PersonalName },
69-
{ labelId: 'ld.corporateName', value: SearchableIndex.CorporateConferenceName },
70-
{ labelId: 'ld.geographicName', value: SearchableIndex.GeographicName },
71-
{ labelId: 'ld.nameTitle', value: SearchableIndex.NameTitle },
72-
{ labelId: 'ld.uniformTitle', value: SearchableIndex.UniformTitle },
73-
{ labelId: 'ld.subject', value: SearchableIndex.Subject },
74-
{ labelId: 'ld.childrensSubjectHeading', value: SearchableIndex.ChildrenSubjectHeading },
75-
{ labelId: 'ld.genre', value: SearchableIndex.Genre },
116+
{
117+
labelId: 'ld.keyword',
118+
value: SearchableIndex.Keyword,
119+
},
120+
{
121+
labelId: 'ld.identifierAll',
122+
value: SearchableIndex.Identifier,
123+
},
124+
{
125+
labelId: 'ld.lccn',
126+
value: SearchableIndex.LCCN,
127+
},
128+
{
129+
labelId: 'ld.personalName',
130+
value: SearchableIndex.PersonalName,
131+
},
132+
{
133+
labelId: 'ld.corporateName',
134+
value: SearchableIndex.CorporateConferenceName,
135+
},
136+
{
137+
labelId: 'ld.geographicName',
138+
value: SearchableIndex.GeographicName,
139+
},
140+
{
141+
labelId: 'ld.nameTitle',
142+
value: SearchableIndex.NameTitle,
143+
},
144+
{
145+
labelId: 'ld.uniformTitle',
146+
value: SearchableIndex.UniformTitle,
147+
},
148+
{
149+
labelId: 'ld.subject',
150+
value: SearchableIndex.Subject,
151+
},
152+
{
153+
labelId: 'ld.childrensSubjectHeading',
154+
value: SearchableIndex.ChildrenSubjectHeading,
155+
},
156+
{
157+
labelId: 'ld.genre',
158+
value: SearchableIndex.Genre,
159+
},
76160
],
77161
},
78162

79163
browse: {
80-
limit: 100,
164+
limit: 100, // UI shows all 100 results per page
81165
features: {
82166
hasSegments: true,
167+
// Disable source toggle in browse segment
83168
hasSourceToggle: false,
84169
hasAdvancedSearch: false,
85170
isLoopedPagination: true,
@@ -88,13 +173,34 @@ export const authoritiesUIConfig: SearchTypeUIConfig = {
88173
isVisibleEmptySearchPlaceholder: true,
89174
},
90175
searchableIndices: [
91-
{ labelId: 'ld.personalName', value: SearchableIndex.PersonalName },
92-
{ labelId: 'ld.corporateName', value: SearchableIndex.CorporateConferenceName },
93-
{ labelId: 'ld.geographicName', value: SearchableIndex.GeographicName },
94-
{ labelId: 'ld.nameTitle', value: SearchableIndex.NameTitle },
95-
{ labelId: 'ld.uniformTitle', value: SearchableIndex.UniformTitle },
96-
{ labelId: 'ld.subject', value: SearchableIndex.Subject },
97-
{ labelId: 'ld.genre', value: SearchableIndex.Genre },
176+
{
177+
labelId: 'ld.personalName',
178+
value: SearchableIndex.PersonalName,
179+
},
180+
{
181+
labelId: 'ld.corporateName',
182+
value: SearchableIndex.CorporateConferenceName,
183+
},
184+
{
185+
labelId: 'ld.geographicName',
186+
value: SearchableIndex.GeographicName,
187+
},
188+
{
189+
labelId: 'ld.nameTitle',
190+
value: SearchableIndex.NameTitle,
191+
},
192+
{
193+
labelId: 'ld.uniformTitle',
194+
value: SearchableIndex.UniformTitle,
195+
},
196+
{
197+
labelId: 'ld.subject',
198+
value: SearchableIndex.Subject,
199+
},
200+
{
201+
labelId: 'ld.genre',
202+
value: SearchableIndex.Genre,
203+
},
98204
],
99205
},
100206
},

0 commit comments

Comments
 (0)