You are here:

dqt – DEPAROM Query Translator

The service is primarily tailored for our DEPAROM Profil customers and anyone else who wants to use queries in the DEPAROM query language to search the DEPAROM index. It provides a RESTful interface to receive DEPAROM queries and returns a matching Elasticsearch query to be used on the DEPAROM index.

Information Required

In order to use the DEPAROM Query Translator you will need a DEPAROM Query to translate. You can get one from your latest DEPAROM volume. Alternatively you can write your own based on the below examples and the documentation of the DEPAROM Recherche Client which is available for download.

Tutorial

n order to send data to the HTTP API you need some form of REST client. This can be a basic tool like cURL, a fully featured REST client like Insomnia or any client library targeted for your development language. For this tutorial we will assume cURL and provide examples as cURL commands, since it is a widely available tool on most operating systems.

We want to send a DEPAROM query to the service, so that we can get a translated query back which we can then use, to query the Elasticsearch index.

We also need to authenticate against the proxy with our credential using http simple authentication. A cURL command would look like the following:

$ curl -u username:password -XPOST 'https://api.depa.tech/dqt/query/es' -H 'Content-Type: application/json' -d '
DEPAROM V1.0
1
(
    (
        IC=B62B0001
        OR IC=B62B0003
    )
    AND
    (
        KI=A* or KI=B* or KI=U*
    )
OR
    PA*=WANZL,CADDIE,MARSANZ
)
AND
(
    PC*=DE,EP,US,WO
)'

This will result in a response which carries the query object in JSON format, ready to be inserted in an Elasticsearch query. The returned output should look like this:

{ "bool": { "must": [{ "bool": { "should": [{ "bool": { "must": [{ "bool": { "should": [{ "term": { "IC": "B62B0001" } }, { "term": { "IC": "B62B0003" } }] } }, { "bool": { "should": [{ "regexp": { "KI": "A.*" } }, { "regexp": { "KI": "B.*" } }, { "regexp": { "KI": "U.*" } }] } }] } }, { "query_string": { "fields": ["PA"], "query": "WANZL", "default_operator": "AND" } }, { "query_string": { "fields": ["PA"], "query": "CADDIE", "default_operator": "AND" } }, { "query_string": { "fields": ["PA"], "query": "MARSANZ", "default_operator": "AND" } }] } }, { "bool": { "should": [{ "term": { "PC": "DE" } }, { "term": { "PC": "EP" } }, { "term": { "PC": "US" } }, { "term": { "PC": "WO" } }] } }] } }

If you are familiar with Elasticsearch queries you will notice, that the payload does not resemble a proper Elasticsearch query. This is on purpose. The returned JSON object is to be used as an inner query object either by embedding it in the root query object or as part of a larger query like a bool query. The most simple approach would look like this:


{"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"should":[{"regexp":{"IC":"B62B0001"}},{"regexp":{"IC":"B62B0003"}}]}},{"bool":{"should":[{"bool":{"should":[{"regexp":{"KI":"A.*"}},{"bool":{"should":[{"regexp":{"KI":"B.*"}},{"regexp":{"KI":"U.*"}}]}}]}},{"bool":{"should":[{"terms":{"PA":["WANZL","CADDIE","MARSANZ"]}}]}}]}}]}},{"bool":{"should":[{"terms":{"PC":["DE","EP","US","WO"]}}]}}]}}}

As you see, the result JSON is set as the „query“ key in the Elasticsearch root query object. For more details on how to query the DEPAROM index, please refer to the Elasticsearch index section of this documentation.

Known Issues

Quotation marks around values

At the moment you are encouraged to put any text value which has a length of 2 characters or less in quotation marks like so: PC=“DE“.
Currently there is a problem with the parser which confuses values which are equal to field names for field names, resulting in an error.

Truncations with asterisk

Truncation currently only work in the KI field, due to a bug in the translator.

API documentation

Translate query

Endpoint/query/es
MethodPOST
NotesSend a query in DEPAROM format in the request body and get a query Elasticsearch format returned.

Usage example:

$ curl -u username:password -XPOST 'https://api.depa.tech/dqt/query/es' -H 'Content-Type: application/json' -d '
DEPAROM V1.0
1
PC=DE
'