Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA2 - ES relevance improvements and query generation refactor #411

Merged
merged 56 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
be68cd7
Add Elastic consultant query additions
nonword May 30, 2024
ea5e9eb
Update test fixtures
nonword May 30, 2024
d40f54c
Add matching on title.keywordNormalized
nonword May 31, 2024
66c7df7
Incorporate latest all, title, and contrib queries
nonword Jun 5, 2024
cc62fe1
Update fixtures
nonword Jun 5, 2024
513a47c
Change: Add uri to relevance sort
nonword Jun 6, 2024
c0101a0
Update v8 prod testing index
nonword Jun 6, 2024
4ca337f
Remove contrib keyword matchers from 'all' search
nonword Jun 6, 2024
15a0881
Update fixtures
nonword Jun 6, 2024
1174576
Fix bug reading numItemsTotal from inner_hits
nonword Jun 10, 2024
35a92f8
Add shingled matcher, 6-7 index
nonword Jun 12, 2024
cc6dec6
Update fixtures
nonword Jun 12, 2024
3d808c3
Update fixtures
nonword Jun 12, 2024
ab04699
Updated standard_number search
nonword Jun 13, 2024
e697a51
Merge remote-tracking branch 'refs/remotes/origin/qa-node20-es-tuning…
nonword Jun 14, 2024
c89975d
Add [wip] work to assess keyword relevance against query targets
nonword Jun 20, 2024
afa687b
Add assess-query-targets script
nonword Jun 21, 2024
b715121
Rebuild fixtures
nonword Jun 24, 2024
62c4296
Merge upstream
nonword Jun 24, 2024
1a3a5dc
Updates from Elastic consulting
nonword Jul 2, 2024
7cfca19
Incorporate Text, EN, popularity boosts
nonword Jul 11, 2024
d5d230b
Disable EN and Text boosting. Add basic prod deploy
nonword Jul 13, 2024
495fc06
Fix gh actions file
nonword Jul 13, 2024
8d30e90
Fix broken standard-number searches
nonword Jul 13, 2024
7691d55
Use new author normalized & w/o-dates fields
nonword Jul 19, 2024
fa018a0
Merge branch 'qa-node20' into qa-node20-es-tuning
nonword Jul 22, 2024
b697e12
Merge branch 'qa-node20' into qa-node20-es-tuning
nonword Jul 22, 2024
b7d72f1
Update packages
nonword Jul 22, 2024
746437c
Use prefix matching on both creator and contrib
nonword Jul 25, 2024
960bdcd
Only boost on popularity for all, title, or contrib searches
nonword Jul 29, 2024
857e3f2
Merge upstream
nonword Aug 9, 2024
7a3fe03
Update to use new qa and prod ES IPs & api-keys
nonword Sep 24, 2024
018c2fa
Updates to handling of quoted searches, basic refactoring
nonword Oct 1, 2024
0ce7c00
Update: better match callnumber queries, new qa index
nonword Oct 8, 2024
4ef8566
Refactor elastic-query
nonword Oct 9, 2024
6539827
Merge branch 'main' into qa2
nonword Oct 9, 2024
698a9bb
Fix imperfect standard-number base query
nonword Oct 10, 2024
9da5959
Refactor elastic query building
nonword Oct 11, 2024
5a6e4ba
Add buildingLocation filter, update swagger
nonword Oct 11, 2024
21921dc
Change buildingLocations agg to buildingLocation
nonword Oct 11, 2024
eee4969
Bump version to debug deployment
nonword Oct 11, 2024
fcb89ee
Fix bug loading qa2 config
nonword Oct 11, 2024
691cc85
Fix issue building fixtures
nonword Oct 11, 2024
9cb2cd0
Use 2024-10-14 qa index
nonword Oct 15, 2024
6c1b0bb
Temporarily deploy qa2 branch to qa
nonword Oct 15, 2024
ee44d51
Fix bug applying filters across search scopes
nonword Oct 16, 2024
ca37f6a
Updates following searchathon testing
nonword Oct 17, 2024
1bb299d
Small updates from feedback
nonword Oct 17, 2024
ea4cd80
Improvements to assess-query-targets script
nonword Oct 17, 2024
75eada0
Fix misleading es utils documentation
nonword Oct 17, 2024
635c3d1
Don't deploy qa2 to qa
nonword Oct 17, 2024
de0409f
Use resources-2024-10-17 qa index
nonword Oct 18, 2024
f1ebec6
Validate uri in findByUri route, add updatedAtDate
nonword Oct 18, 2024
48772b2
Merge branch 'qa2' into qa2-refactor-searchathon-fixes
nonword Oct 18, 2024
2173ce7
Merge pull request #412 from NYPL/qa2-refactor-searchathon-fixes
nonword Oct 18, 2024
f29693c
Fix broken test after merge
nonword Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For local development, it's easiest to just use local node binaries:

```
nvm use; npm i
nvm use; ENV=qa npm start
nvm use; ENV=qa LOCAL=true npm start
```

Note that when developing locally, if connecting to a IP ACL protected index (a practice we're currently deprecating), you may need to [add your IP to the access control policy of the relevant ES domain](https://github.com/NYPL/aws/blob/b5c0af0ec8357af9a645d8b47a5dbb0090966071/common/elasticsearch.md#2-make-the-domain-public-restrict-by-ip). If your IP has not been authorized, you will see errors such as the following in the application logs:
Expand Down
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const express = require('express')

const esClient = require('./lib/es-client')
const esClient = require('./lib/elasticsearch/client')
const loadConfig = require('./lib/load-config')
const { preflightCheck } = require('./lib/preflight_check')

const swaggerDocs = require('./swagger.v1.1.x.json')

const pjson = require('./package.json')

const app = express()
Expand Down Expand Up @@ -52,6 +53,8 @@ app.init = async () => {
app.get('/api/v0.1/discovery/swagger', function (req, res) {
res.send(swaggerDocs)
})

return app
}

app.start = async () => {
Expand Down
10 changes: 7 additions & 3 deletions config/production.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Currently, this is our ES 5.3 for Prod:
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAMMwgcAGCSqGSIb3DQEHBqCBsjCBrwIBADCBqQYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyUXsOWkXt7ZqqD7uQCARCAfMIrLEGKd51lkX/hzWYlUms176JOee1HhdP/WIf5nd3xTwXJz1m4yOWwDsefoJEL4sez/2ZP43MVds+1lcM3PwkHMyN01sa2xpwVDrT68A/f22bDMtp6A9BmJqr7VBB5oq2j4FoXu2+0uaQWQRWJ0Ns+vQ6nbiR5V4Vv8zE=
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDF+IpeiMrtx/UveMsgIBEIAvIolGVXJPBMseyyep3/fyf/qP+KdATwfxT6Gw4dnatbiL5609NBeyyLNIprEM90g=
# Greg built self-hosted production domain:
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJYwgZMGCSqGSIb3DQEHBqCBhTCBggIBADB9BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDFWw8ECX9Pz81z0kvAIBEIBQGec9PCpwuvEgLH6imhqP6tx1fj8Vlf2ZipnUy06jzmpE262Qvk9LPAq7sIYPVkTCZctwilwcU9oC6yxasVoUlK87la77v03CeZsPIDwciFY=
# 2024-07-11:
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDGBdRKmRzMe2BVCBQAIBEIAvOT7nIumnss0wJN0N4tSrhW+wh7lJ7yr7VwQhe7TVUJEmADJDEnnyvm18FMLBR4c=
charmingduchess marked this conversation as resolved.
Show resolved Hide resolved
ENCRYPTED_ELASTICSEARCH_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJ4wgZsGCSqGSIb3DQEHBqCBjTCBigIBADCBhAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyPOPaQCBbvKQhJoPQCARCAV2TlWlRh+xKnCegpprEQgfldZGcVW48RND0LVd/pQpVTJnRTtbCpP7damT7k8ziJVdWZ3jsfs5fw5YnKc/EIQ1M//DRUzOJL98ir5LTTxE7QhflKDtUY+Q==


ENCRYPTED_SCSB_URL=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHwwegYJKoZIhvcNAQcGoG0wawIBADBmBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDKPFC8wFkVM5CyT6VQIBEIA5m4eLBkpChRA//ZNEWsRqIDGZmevb/thzI03a0NiAW6VfybSAYpFthh+bj/yAk1VEEBF6r1T4A2GP
ENCRYPTED_SCSB_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAIMwgYAGCSqGSIb3DQEHBqBzMHECAQAwbAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAw8tglwVzGKBduDD9wCARCAP4biSz13FvZVHyQ8LKCb0+uLcKUKmzWqC5abVJI0kTmQJvjr9ViHsuP9/qj94Y8E7K96sb+fn0+HZk8So6CssA==
Expand All @@ -13,6 +16,7 @@ ENCRYPTED_NYPL_OAUTH_SECRET=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAA
NYPL_CORE_VERSION=v2.21

LOG_LEVEL=info
NAME_QUERIES=true
FEATURES=on-site-edd

SEARCH_ITEMS_SIZE=3
Expand Down
24 changes: 0 additions & 24 deletions config/qa-new-domain.env

This file was deleted.

9 changes: 6 additions & 3 deletions config/qa.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Currently, this is our ES 5.3 for QA:
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAALswgbgGCSqGSIb3DQEHBqCBqjCBpwIBADCBoQYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyWLvUSzA/IAQCHl0MCARCAdNpF/Z1VJESwJ7hcwo/BqZz2mTDPA9NAPQ4zuPLsItz9A2lfHaP03bPuo9nq8VP5AKLOa4zPL0VoBmwEjj9qCCb+LSpQ3m+OoyM3BxG98/qYEcwXXOa8+0fH1x5asVrup/YICJdeD6jOewxttzzxCCGXEklL
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDI88/9macimvmLyWCAIBEIAvMUOAtF2Miq+8u7/A9fzBz57LavqkeLJmv8dd7WQzdA9lhqPkjUK0pzYtxsPe6Nk=
# Greg built self-hosted qa domain:
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJYwgZMGCSqGSIb3DQEHBqCBhTCBggIBADB9BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMIkDoQ9C/cCDCAq1wIBEIBQ+L3OgUGeOW9rs1CWkhpBjwM4LbbVRFIWedqew4UXIeSNMJ8cO9SNe4YGCUIoKwCDYt7W7ip3VtDRRRMVvz6QJw+Eg8ugTMVs2pbNFGNvaAQ=
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDEQrZlNp930LqpZVywIBEIAvpxx39QAHfdY1+Lxv54TnDVW3M5cSHiyTbuhaJgDK/3y+5iHyw6Y0MmtGdgnl5jQ=
ENCRYPTED_ELASTICSEARCH_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJ4wgZsGCSqGSIb3DQEHBqCBjTCBigIBADCBhAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAx+kryf2KUmGdBYD9sCARCAV3ygz3eXIdq8JX/wpG9JRWlTNMRcpNE1qT0zNlN4t+ZvXEoedLQa/3p1YjgHw06GIAdA9xtkMV4eH9a1K8uCvjP8XxxNKekcMj59TlResnu9QF3r7pGXuQ==

ENCRYPTED_SCSB_URL=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAH8wfQYJKoZIhvcNAQcGoHAwbgIBADBpBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDBKllElmWYLxGOGopQIBEIA8JJyKde/8m8iCJGKR5D8HoTJhXHeyvw9eIDeuUNKiXLfJwoVz+PDAZSxkCQtM9O91zGhXbe3l6Bk1RlYJ
ENCRYPTED_SCSB_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGMwYQYJKoZIhvcNAQcGoFQwUgIBADBNBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDNw8KXkyN8HvtjAX0gIBEIAgX+XG2fxTj6kSchrd/dfHB05KU5pkT0LtPxUTuNCXoLc=
Expand All @@ -22,3 +23,5 @@ HIDE_NYPL_SOURCE=

BIB_HAS_VOLUMES_THRESHOLD=0.8
BIB_HAS_DATES_THRESHOLD=0.8

NAME_QUERIES=true
71 changes: 71 additions & 0 deletions lib/api-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* This class wraps request params to ease interpretting the query
**/

class ApiRequest {
static ADVANCED_SEARCH_PARAMS = ['title', 'subject', 'contributor']
static IDENTIFIER_NUMBER_PARAMS = ['isbn', 'issn', 'lccn', 'oclc']

constructor (params) {
this.params = params

// Make some substitutions for folks querying with "date:1997", etc
if (this.params.q) {
this.params.q = this.params.q
.replace(/date:/g, 'dateStartYear:')
.replace(/location:/g, 'locations:')
.replace(/subject:/g, 'subjectLiteral:')
}
}

/**
* Get array of params in the query that are also valid search-scopes:
*/
advancedSearchParamsThatAreAlsoScopes () {
// Return search params that are also valid search_scope values
return ApiRequest.ADVANCED_SEARCH_PARAMS
.filter((key) => this.params[key])
}

hasKeyword () {
return !!this.params.q
}

hasSearch () {
return this.hasKeyword() || this.advancedSearchParamsThatAreAlsoScopes().length > 0
}

/**
* Returns true if search_scope matches one of the named scopes
**/
hasScope (scopes) {
return scopes.includes(this.params.search_scope)
}

/**
* Returns true if query is fully wrapped in quotes
**/
queryIsFullyQuoted () {
return /^"[^"]+"$/.test(this.params.q)
charmingduchess marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Get keyword query without surrounding quotes (if fully quoted)
**/
querySansQuotes () {
return this.queryIsFullyQuoted()
? this.params.q.substring(1, this.params.q.length - 1)
: this.params.q
}

hasIdentifierNumberParam () {
return Object.keys(this.params)
.some((userParam) => ApiRequest.IDENTIFIER_NUMBER_PARAMS.includes(userParam))
}

static fromParams (params) {
return new ApiRequest(params)
}
}

module.exports = ApiRequest
11 changes: 8 additions & 3 deletions lib/availability_resolver.js
charmingduchess marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const scsbClient = require('./scsb-client')
const logger = require('./logger')
const ResourceSerializer = require('./jsonld_serializers').ResourceSerializer
const NyplSourceMapper = require('discovery-store-models/lib/nypl-source-mapper')
const { nonRecapItemStatusAggregation } = require('./es-client')
const { nonRecapItemStatusAggregation } = require('./elasticsearch/client')
const { deepValue, isInRecap } = require('./util')

const ITEM_STATUSES = {
Expand Down Expand Up @@ -94,7 +94,9 @@ class AvailabilityResolver {
logger.debug('_fixItemStatusAggregation: Skipping because no SCSB statuses provided')
return Promise.resolve()
}
const bnum = resp.hits.hits[0]._id
const bnum = resp.hits.hits[0]?._id
if (!bnum) return Promise.resolve()

const { nyplSource } = NyplSourceMapper.instance().splitIdentifier(bnum)

// Get total number of items:
Expand Down Expand Up @@ -135,7 +137,10 @@ class AvailabilityResolver {
nonRecapStatusAggregation
)
logger.debug(`_fixItemStatusAggregation: Final aggregation: ${JSON.stringify(resp.aggregations.item_status._nested.buckets)}`)
}).catch((e) => console.error('Got error: ', e))
}).catch((e) => {
console.error('Got error: ', e)
return Promise.resolve()
})
}
}

Expand Down
48 changes: 35 additions & 13 deletions lib/es-client.js → lib/elasticsearch/client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const elasticsearch = require('@elastic/elasticsearch')
const url = require('node:url')
const { deepValue } = require('./util')
const logger = require('./logger')
const { IndexConnectionError } = require('./errors')
const { deepValue } = require('../util')
const logger = require('../logger')
const { IndexConnectionError } = require('../errors')

const clientWrapper = {}

Expand All @@ -11,16 +11,38 @@ const clientWrapper = {}
*/
clientWrapper.esClient = function () {
if (!this._esClient) {
// Parse ES connection string:
const { protocol, auth, host, port } = url.parse(process.env.ELASTICSEARCH_URI)
const [username, password] = auth ? auth.split(':') : []
const options = {
node: `${protocol}//${host}`,
port,
auth: { username, password }
// Parse ES connection string, which is likely multiple http base URIs
// separated by a comma:
const elasticUris = process.env.ELASTICSEARCH_URI.split(',')
const urisParsed = elasticUris.map((uri) => {
// Extract parts of the URI:
const { protocol, auth, host } = url.parse(uri)
const [username, password] = auth ? auth.split(':') : []
return {
protocol,
host,
username,
password
}
})
// Build ES client connection config:
const config = {}
config.nodes = urisParsed.map((uri) => `${uri.protocol}//${uri.host}`)

// Configure auth:
if (process.env.ELASTICSEARCH_API_KEY) {
// Auth with `apiKey`:
config.auth = { apiKey: process.env.ELASTICSEARCH_API_KEY }
} else if (urisParsed[0].username) {
// Auth with username, password:
config.auth = { username: urisParsed[0].username, password: urisParsed[0].password }
}
logger.info(`Connecting to ES at ${host}:${port} ${username && password ? 'with creds' : 'w/out creds'}`)
this._esClient = new elasticsearch.Client(options)

// Log out some of the connection details for debugging purposes:
const authMethod = urisParsed[0].username ? 'with creds' : (process.env.ELASTICSEARCH_API_KEY ? 'with apiKey' : 'w/out creds')
logger.info(`Connecting to ES at ${urisParsed.map((u) => u.host).join(',')}/${process.env.RESOURCES_INDEX} ${authMethod}`)

this._esClient = new elasticsearch.Client(config)
}
return this._esClient
}.bind(clientWrapper)
Expand All @@ -30,7 +52,7 @@ clientWrapper.esClient = function () {
* the configured ES
*/
clientWrapper.search = function (body) {
logger.debug(`Performing ES search: ${JSON.stringify(body)}`)
logger.debug(`Performing ES search: ${JSON.stringify(body, null, 2)}`)
return this.esClient().search({
index: process.env.RESOURCES_INDEX,
body
Expand Down
100 changes: 100 additions & 0 deletions lib/elasticsearch/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Configure search scopes:
const SEARCH_SCOPES = {
all: {
fields: [
'title^5',
'title.folded^2',
'description.folded',
'subjectLiteral^2',
'subjectLiteral.folded',
'creatorLiteral^2',
'creatorLiteral.folded',
'contributorLiteral.folded',
'note.label.folded',
'publisherLiteral.folded',
'seriesStatement.folded',
'titleAlt.folded',
'titleDisplay.folded',
'contentsTitle.folded',
'donor.folded',
'parallelTitle.folded^5',
'parallelTitleDisplay.folded',
'parallelTitleAlt.folded',
'parallelSeriesStatement.folded',
'parallelCreatorLiteral.folded',
'parallelPublisher',
'uniformTitle.folded',
'parallelUniformTitle',
'formerTitle',
'addedAuthorTitle',
'placeOfPublication',
{ field: 'items.idBarcode', on: (q) => /\d{6,}/.test(q) },
// Try to detect shelfmark searches (e.g. JFD 16-5143)
{ field: 'items.shelfMark', on: (q) => /^[A-Z]{1,3} \d{2,}/.test(q) }
]
},
title: {
fields: [
'title^5',
'title.folded^2',
'titleAlt.folded',
'uniformTitle.folded',
'titleDisplay.folded',
'seriesStatement.folded',
'contentsTitle.folded',
'donor.folded',
'parallelTitle.folded^5',
charmingduchess marked this conversation as resolved.
Show resolved Hide resolved
'parallelTitleDisplay.folded',
'parallelSeriesStatement.folded',
'parallelTitleAlt.folded',
'parallelCreatorLiteral.folded',
'parallelUniformTitle',
'formerTitle',
'addedAuthorTitle'
]
},
contributor: {
fields: ['creatorLiteral^4', 'creatorLiteral.folded^2', 'contributorLiteral.folded', 'parallelCreatorLiteral.folded', 'parallelContributorLiteral.folded']
},
subject: {
fields: ['subjectLiteral^2', 'subjectLiteral.folded', 'parallelSubjectLiteral.folded']
},
series: {
fields: ['seriesStatement.folded']
},
callnumber: {
fields: null
},
standard_number: {
fields: null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these fields null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically, all search-scopes were configured in this const - with an array of fields to use in the query_string/multi-match query. With ES search improvements, two of these search-scopes don't use multi-match at all, so there's no need for a central config. However, this const remains a central, authoritative config for what search-scopes are available. I think future refactoring may change this, but for now I've just removed the fields prop from these search-scopes and added a comment to clarify

}
}

const FILTER_CONFIG = {
owner: { operator: 'match', field: 'items.owner_packed', repeatable: true, path: 'items' },
subjectLiteral: { operator: 'match', field: 'subjectLiteral_exploded', repeatable: true },
holdingLocation: { operator: 'match', field: 'items.holdingLocation_packed', repeatable: true, path: 'items' },
buildingLocation: { operator: 'match', field: 'buildingLocationIds', repeatable: true },
language: { operator: 'match', field: 'language_packed', repeatable: true },
materialType: { operator: 'match', field: 'materialType_packed', repeatable: true },
mediaType: { operator: 'match', field: 'mediaType_packed', repeatable: true },
carrierType: { operator: 'match', field: 'carrierType_packed', repeatable: true },
publisher: { operator: 'match', field: 'publisherLiteral.raw', repeatable: true },
contributorLiteral: { operator: 'match', field: 'contributorLiteral.raw', repeatable: true },
creatorLiteral: { operator: 'match', field: 'creatorLiteral.raw', repeatable: true },
issuance: { operator: 'match', field: 'issuance_packed', repeatable: true },
createdYear: { operator: 'match', field: 'createdYear', repeatable: true },
dateAfter: {
operator: 'custom',
type: 'int'
},
dateBefore: {
operator: 'custom',
type: 'int'
}
}

module.exports = {
SEARCH_SCOPES,
FILTER_CONFIG
}
Loading
Loading