How to use the standard query format: "q" parameter
MAPEGY API supports advanced search functionalities through the standard "q" parameter. Below is an overview of the search types available and how they are applied using q
.
Types of Search
MAPEGY API supports two search types:
- Advanced search (Boolean): Uses logical operators like AND, OR, and NOT to filter results based on keywords.’
- Semantic search: Uses natural language processing to find results that match the search intent.
- Semantic Search is designed for topic-based searches. For organization-specific searches, use Advanced Search. When activating Semantic search, Advanced search will be limited to organizations.
- Combining Semantic Search with Organization advanced search esis technically possible via the API, but this functionality is currently unstable and not recommended.
For reliable results when searching for both a topic and an organization, use Advanced Search.
For more details, visit this page.
The "q" parameter:
The q parameter is the standard query format for interacting with MAPEGY APIs. It allows users to search using both Semantic Search and Advanced (Boolean) Search.
Below is an example in JavaScript showing how to structure a query using the q
parameter:
function ScoutQuery() {
this.format_version = '1.6.0';
this.data = {
/*
SEMANTIC SEARCH
If used, ADVANCED SEARCH is limited to "organizations" in the format [[x1,x2,...]].
*/
semantic: ''
/*
ADVANCED SEARCH
Each field contains a nested array of search terms in the format [[x1,x2,...], [y1,y2,...], ...]
which represents the Boolean query (x1 OR x2 OR ...) AND (y1 OR y2 OR ...) AND ...
*/
// Topic names
topics: [],
not_topics: [], // AND NOT (...)
// Organization names
organizations: [],
not_organizations: [], // AND NOT (...)
};
};
// initialize query
var query = new ScoutQuery();
// add terms to query
query.data.topics.push(['artificial intelligence', 'deep learning']);
// build url
var queryParam = '?q=' + encodeURIComponent(JSON.stringify(query));
var route = 'Documents';
var url = 'https://api-dev.mapegy.com/' + route + '/' + queryParam;
Related articles