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.

MAPEGY API search uses logical operators like AND, OR, and NOT to filter results based on keywords.

You can use the Autosuggest API to generate these queries using natural language.

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:

// example in JavaScript

function ScoutQuery() {
	this.format_version = '1.6.0';
	this.data = {
		/*
			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.mapegy.com/' + route + '/' + queryParam;

Related articles