1.0.19 • Published 2 years ago

search-request v1.0.19

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

search-request

npm module containing shared components for search

Installation

npm i search-request

Usage

Javascript

import searchRequest from 'search-request'
/* OR */
const searchRequest = require('search-request')

addRefinement(request, node)

Add a single refinement node to an existing Search API request object. The request.query may be of type 'terminal' or 'group'. The node to be added may be of type 'terminal' or 'group' but the 'group' type should only be used for 'nested' attribute pairs. This function is called primarily from the 'groups' landing page. Examples:

Add a terminal node for a single attribute:
const searchRequest = require('search-request');
const request = { ... } // existing Search API request object
const node = {
        "type": "terminal",
        "service": "text",
        "parameters": {
            "attribute": "exptl.method",
            "operator": "exact_match",
            "value": "ELECTRON MICROSCOPY"
        }
    }

searchRequest.addRefinement(request, node)
Add a group node for a single nested attribute pair:

For nested attribute pairs, the number and order of the nodes in the group is important. The nested attribute must be the second of 2 terminal nodes.

const request = { ... } // existing Search API request object
const node = {
        "type": "group",
        "nodes": [
            {
                "type": "terminal",
                "service": "text",
                "parameters": {
                    "attribute": "rcsb_polymer_instance_annotation.annotation_lineage.id",
                    "operator": "exact_match",
                    "value": "2"
                }
            },
            {
                "type": "terminal",
                "service": "text",
                "parameters": {
                    "attribute": "rcsb_polymer_instance_annotation.type",
                    "operator": "exact_match",
                    "value": "CATH"
                }
            }
        ],
        "logical_operator": "and"
    }

searchRequest.addRefinement(request, node)

Add multiple refinements:

Add multiple refinements to an existing Search API request object. This function is called primarily to handle one or more selections made in the Search UI Refinement panel.

const request = { ... } // existing Search API request object
const refinements = [
        {
            attribute: "rcsb_entity_source_organism.ncbi_scientific_name",
            values: [
                "Homo sapiens",
                "Human immunodeficiency virus"
            ]
        },
        {
            attribute: "rcsb_entry_info.resolution_combined",
            values: [
                "*-0.5",
                "0.5-1.0"
            ]
        }
    ]

searchRequest.addRefinements(request, refinements)
1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago