Skip to main content

Search a single object type

GraphQL query

Use semantic search to retrieve the most relevant items for a specific object type. The example below searches addresses with unstructured text input (for example: "warehouse near Berlin").


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": "Find a warehouse or distribution center near Berlin with loading docks",
"objectType": ["ADDRESS"],
"limit": 5,
"minScore": 0.7
}
},
"query": `
query SemanticSearch($query: SemanticSearchQuery!) {
semanticSearch(query: $query) {
items {
... on Address {
_id
city
street
zipcode
country
}
__typename
}
__typename
}
}
`
}
]),
method: "POST"
});

[
{
"data": {
"semanticSearch": {
"items": [
{
"_id": "66b8bb0e25c150b2d301e1ee",
"city": "Berlin",
"street": "Alexanderplatz",
"zipcode": "10178",
"country": "de",
"__typename": "Address"
}
],
"__typename": "SemanticSearchResults"
}
}
}
]

To target another single object type, update objectType accordingly (for example ["CUSTOMER"]).