Search across multiple object types
Search several object types in one request to surface the most relevant entities regardless of their type. This example searches addresses and customers at the same time.
- NodeJS
const fetch = require("node-fetch")
fetch("https://backend.impargo.eu/", {
headers: {
"authorization": token,
"content-type": "application/json",
},
body: JSON.stringify([
{
"operationName": "SemanticSearch",
"variables": {
"query": {
"text": "Logistics hub near Berlin working with international freight partners",
"objectType": ["ADDRESS", "CUSTOMER"],
"limit": 5,
"minScore": 0.7
}
},
"query": `
query SemanticSearch($query: SemanticSearchQuery!) {
semanticSearch(query: $query) {
items {
... on Address {
_id
city
street
zipcode
country
}
... on Customer {
_id
name
email
}
__typename
}
__typename
}
}
`
}
]),
method: "POST"
});
- Response
[
{
"data": {
"semanticSearch": {
"items": [
{
"_id": "66b8bb0e25c150b2d301e1ee",
"city": "Berlin",
"street": "Alexanderplatz",
"zipcode": "10178",
"country": "de",
"__typename": "Address"
},
{
"_id": "66b8bb0e25c150b2d301e1ef",
"name": "Logistics GmbH",
"email": "info@logistics.de",
"__typename": "Customer"
}
],
"__typename": "SemanticSearchResults"
}
}
}
]
Add new object types by including them in objectType (for example ["ADDRESS", "CUSTOMER"]).