Create a query rewrite
import requests
url = "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites"
payload = { "type": "HEAD_TAIL" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"HEAD_TAIL\"\n}")
.asString();const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: 'HEAD_TAIL'})
};
fetch('https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"HEAD_TAIL\"\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites"
payload := strings.NewReader("{\n \"type\": \"HEAD_TAIL\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'HEAD_TAIL'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "HEAD_TAIL"
}
'{
"type": "HEAD_TAIL",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdBy": "<string>",
"creationDate": "2023-11-07T05:31:56Z",
"lastModifiedBy": "<string>",
"lastModified": "2023-11-07T05:31:56Z",
"published": true,
"version": "2023-11-07T05:31:56Z",
"stagingFusionSyncStatus": {
"lastSyncedVersion": "2023-11-07T05:31:56Z",
"fusionVersion": "<string>"
},
"liveFusionSyncStatus": {
"lastSyncedVersion": "2023-11-07T05:31:56Z",
"fusionVersion": "<string>"
},
"markedForDeletion": true,
"description": "<string>",
"externalId": "<string>",
"migratedId": "<string>",
"surfaceForm": "<string>",
"outputs": [
"<string>"
]
}Create a query rewrite
Create a query rewrite in Commerce Studio.
POST
/
query-rewrites
Create a query rewrite
import requests
url = "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites"
payload = { "type": "HEAD_TAIL" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"HEAD_TAIL\"\n}")
.asString();const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: 'HEAD_TAIL'})
};
fetch('https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"HEAD_TAIL\"\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites"
payload := strings.NewReader("{\n \"type\": \"HEAD_TAIL\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'HEAD_TAIL'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://{commerce_studio_id}.experiencemanager.lucidworks.com/query-rewrites \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "HEAD_TAIL"
}
'{
"type": "HEAD_TAIL",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdBy": "<string>",
"creationDate": "2023-11-07T05:31:56Z",
"lastModifiedBy": "<string>",
"lastModified": "2023-11-07T05:31:56Z",
"published": true,
"version": "2023-11-07T05:31:56Z",
"stagingFusionSyncStatus": {
"lastSyncedVersion": "2023-11-07T05:31:56Z",
"fusionVersion": "<string>"
},
"liveFusionSyncStatus": {
"lastSyncedVersion": "2023-11-07T05:31:56Z",
"fusionVersion": "<string>"
},
"markedForDeletion": true,
"description": "<string>",
"externalId": "<string>",
"migratedId": "<string>",
"surfaceForm": "<string>",
"outputs": [
"<string>"
]
}Authorizations
Query Parameters
Body
application/json
- HeadTailQueryRewriteRequest
- MisspellingQueryRewriteRequest
- PhraseQueryRewriteRequest
- RemoveWordsQueryRewriteRequest
- SynonymQueryRewriteRequest
Replace underperforming queries with queries that produce higher click-through rates.
Response
201 - application/json
Created
- HeadTailQueryRewriteSummary
- MisspellingQueryRewriteSummary
- PhraseQueryRewriteSummary
- RemoveWordsQueryRewriteSummary
- SynonymQueryRewriteSummary
Replace underperforming queries with queries that produce higher click-through rates.
True if this rewrite is marked for deletion but has not yet been fully removed from the system. This should only show up as true in rare cases. The system is supposed to resolve this situation eventually. Rewrites in this state (true) should not show up in the listing endpoints (other than GET by ID) unless explicitly requested to be included. Intended for troubleshooting purposes.
Was this page helpful?