Skip to content

Commit

Permalink
Merge pull request #245 from NYPL/scc-3077
Browse files Browse the repository at this point in the history
Add extra should clause for standard number search
  • Loading branch information
danamansana authored May 10, 2022
2 parents 2ecab10 + 93e4555 commit 688de71
Show file tree
Hide file tree
Showing 21 changed files with 26,261 additions and 7 deletions.
10 changes: 10 additions & 0 deletions lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,16 @@ const buildElasticQueryForKeywords = function (params) {
}
})

if (params.search_scope === 'standard_number') {
should.push({
'query_string': {
'fields': fieldMap._root,
'query': `"${escapeQuery(params.q)}"`,
'default_operator': 'AND'
}
})
}

// Add nested queries (if any) to things that *should* match:
Object.keys(fieldMap)
.filter((nestedName) => nestedName !== '_root')
Expand Down
215 changes: 215 additions & 0 deletions test/fixtures/query-051dba442f346e10c5385430073e7786.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
{
"took": 263,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 117.01943,
"hits": [
{
"_index": "resources-2018-04-09",
"_type": "resource",
"_id": "b12423567",
"_score": 117.01943,
"_source": {
"extent": [
"202 p."
],
"nyplSource": [
"sierra-nypl"
],
"subjectLiteral_exploded": [
"Campanella, Tommaso, 1568-1639"
],
"publisherLiteral": [
"S. Neaulme,"
],
"language": [
{
"id": "lang:lat",
"label": "Latin"
}
],
"createdYear": [
1741
],
"type": [
"nypl:Item"
],
"title": [
"Vita Th. Campanellae."
],
"shelfMark": [
"AN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
],
"creatorLiteral": [
"Cyprian, Ernst Salomon, 1673-1745."
],
"createdString": [
"1741"
],
"dateStartYear": [
1741
],
"identifierV2": [
{
"type": "bf:ShelfMark",
"value": "AN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
},
{
"type": "nypl:Bnumber",
"value": "12423567"
},
{
"type": "bf:Identifier",
"value": "(WaOLN)nyp2408048"
}
],
"updatedAt": 1636321232714,
"publicationStatement": [
"Trajecti ad Rhenum, S. Neaulme, 1741."
],
"identifier": [
"urn:bnum:12423567",
"urn:undefined:(WaOLN)nyp2408048"
],
"materialType": [
{
"id": "resourcetypes:txt",
"label": "Text"
}
],
"carrierType": [
{
"id": "carriertypes:nc",
"label": "volume"
}
],
"dateString": [
"1741"
],
"mediaType": [
{
"id": "mediatypes:n",
"label": "unmediated"
}
],
"subjectLiteral": [
"Campanella, Tommaso, 1568-1639."
],
"titleDisplay": [
"Vita Th. Campanellae. Autore Ern. Sal. Cypriano. Accedunt hac secunda editione appendices IV. doctorum virorum de Campanellae vita, philosophia & libris schediasmata complectentes."
],
"uri": "b12423567",
"numItems": [
1
],
"numAvailable": [
1
],
"placeOfPublication": [
"Trajecti ad Rhenum,"
],
"issuance": [
{
"id": "urn:biblevel:m",
"label": "monograph/item"
}
],
"dimensions": [
"16 cm."
]
},
"inner_hits": {
"items": {
"hits": {
"total": 1,
"max_score": null,
"hits": [
{
"_nested": {
"field": "items",
"offset": 0
},
"_score": null,
"_source": {
"uri": "i16020288",
"status": [
{
"id": "status:a",
"label": "Available"
}
],
"status_packed": [
"status:a||Available"
],
"catalogItemType": [
{
"id": "catalogItemType:2",
"label": "book non-circ"
}
],
"catalogItemType_packed": [
"catalogItemType:2||book non-circ"
],
"holdingLocation": [
{
"id": "loc:mal92",
"label": "Schwarzman Building M2 - General Research Room 315"
}
],
"holdingLocation_packed": [
"loc:mal92||Schwarzman Building M2 - General Research Room 315"
],
"shelfMark": [
"AN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
],
"identifierV2": [
{
"value": "AN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)",
"type": "bf:ShelfMark"
},
{
"type": "bf:Barcode",
"value": "33433104031624"
}
],
"physicalLocation": [
"AN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
],
"identifier": [
"urn:barcode:33433104031624"
],
"idBarcode": [
"33433104031624"
],
"requestable": [
false
],
"accessMessage": [
{
"id": "accessMessage:u",
"label": "Supervised use"
}
],
"accessMessage_packed": [
"accessMessage:u||Supervised use"
],
"shelfMark_sort": "aAN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
},
"sort": [
"aAN (Campanella) (Cyprian, E. S. Vita Th. Campanellae)"
]
}
]
}
}
}
}
]
}
}
Loading

0 comments on commit 688de71

Please sign in to comment.