Hybrid Search
curl --request POST \
--url https://api.sophra.org/api/cortex/search \
--header 'Content-Type: */*' \
--data '
"\"{\\n \\\"index\\\": \\\"{{test_index_name}}\\\",\\n \\\"searchType\\\": \\\"hybrid\\\",\\n \\\"textQuery\\\": {\\n \\\"query\\\": \\\"{{search_query}}\\\",\\n \\\"fields\\\": [\\\"title\\\", \\\"content\\\"],\\n \\\"operator\\\": \\\"AND\\\"\\n },\\n \\\"vectorQuery\\\": {\\n \\\"vector\\\": [{{test_doc_embeddings}}],\\n \\\"field\\\": \\\"embeddings\\\",\\n \\\"k\\\": 2\\n },\\n \\\"boost\\\": {\\n \\\"text\\\": 0.4,\\n \\\"vector\\\": 0.2\\n },\\n \\\"from\\\": 0,\\n \\\"size\\\": 10\\n}\""
'import requests
url = "https://api.sophra.org/api/cortex/search"
payload = "\"{\n \\"index\\": \\"{{test_index_name}}\\",\n \\"searchType\\": \\"hybrid\\",\n \\"textQuery\\": {\n \\"query\\": \\"{{search_query}}\\",\n \\"fields\\": [\\"title\\", \\"content\\"],\n \\"operator\\": \\"AND\\"\n },\n \\"vectorQuery\\": {\n \\"vector\\": [{{test_doc_embeddings}}],\n \\"field\\": \\"embeddings\\",\n \\"k\\": 2\n },\n \\"boost\\": {\n \\"text\\": 0.4,\n \\"vector\\": 0.2\n },\n \\"from\\": 0,\n \\"size\\": 10\n}\""
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify('"{\n \"index\": \"{{test_index_name}}\",\n \"searchType\": \"hybrid\",\n \"textQuery\": {\n \"query\": \"{{search_query}}\",\n \"fields\": [\"title\", \"content\"],\n \"operator\": \"AND\"\n },\n \"vectorQuery\": {\n \"vector\": [{{test_doc_embeddings}}],\n \"field\": \"embeddings\",\n \"k\": 2\n },\n \"boost\": {\n \"text\": 0.4,\n \"vector\": 0.2\n },\n \"from\": 0,\n \"size\": 10\n}"')
};
fetch('https://api.sophra.org/api/cortex/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/search",
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('"{\\n \\"index\\": \\"{{test_index_name}}\\",\\n \\"searchType\\": \\"hybrid\\",\\n \\"textQuery\\": {\\n \\"query\\": \\"{{search_query}}\\",\\n \\"fields\\": [\\"title\\", \\"content\\"],\\n \\"operator\\": \\"AND\\"\\n },\\n \\"vectorQuery\\": {\\n \\"vector\\": [{{test_doc_embeddings}}],\\n \\"field\\": \\"embeddings\\",\\n \\"k\\": 2\\n },\\n \\"boost\\": {\\n \\"text\\": 0.4,\\n \\"vector\\": 0.2\\n },\\n \\"from\\": 0,\\n \\"size\\": 10\\n}"'),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/search"
payload := strings.NewReader("\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/search")
.header("Content-Type", "*/*")
.body("\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\""
response = http.request(request)
puts response.read_bodyCortex > Search Operations
Hybrid Search
POST
/
cortex
/
search
Hybrid Search
curl --request POST \
--url https://api.sophra.org/api/cortex/search \
--header 'Content-Type: */*' \
--data '
"\"{\\n \\\"index\\\": \\\"{{test_index_name}}\\\",\\n \\\"searchType\\\": \\\"hybrid\\\",\\n \\\"textQuery\\\": {\\n \\\"query\\\": \\\"{{search_query}}\\\",\\n \\\"fields\\\": [\\\"title\\\", \\\"content\\\"],\\n \\\"operator\\\": \\\"AND\\\"\\n },\\n \\\"vectorQuery\\\": {\\n \\\"vector\\\": [{{test_doc_embeddings}}],\\n \\\"field\\\": \\\"embeddings\\\",\\n \\\"k\\\": 2\\n },\\n \\\"boost\\\": {\\n \\\"text\\\": 0.4,\\n \\\"vector\\\": 0.2\\n },\\n \\\"from\\\": 0,\\n \\\"size\\\": 10\\n}\""
'import requests
url = "https://api.sophra.org/api/cortex/search"
payload = "\"{\n \\"index\\": \\"{{test_index_name}}\\",\n \\"searchType\\": \\"hybrid\\",\n \\"textQuery\\": {\n \\"query\\": \\"{{search_query}}\\",\n \\"fields\\": [\\"title\\", \\"content\\"],\n \\"operator\\": \\"AND\\"\n },\n \\"vectorQuery\\": {\n \\"vector\\": [{{test_doc_embeddings}}],\n \\"field\\": \\"embeddings\\",\n \\"k\\": 2\n },\n \\"boost\\": {\n \\"text\\": 0.4,\n \\"vector\\": 0.2\n },\n \\"from\\": 0,\n \\"size\\": 10\n}\""
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify('"{\n \"index\": \"{{test_index_name}}\",\n \"searchType\": \"hybrid\",\n \"textQuery\": {\n \"query\": \"{{search_query}}\",\n \"fields\": [\"title\", \"content\"],\n \"operator\": \"AND\"\n },\n \"vectorQuery\": {\n \"vector\": [{{test_doc_embeddings}}],\n \"field\": \"embeddings\",\n \"k\": 2\n },\n \"boost\": {\n \"text\": 0.4,\n \"vector\": 0.2\n },\n \"from\": 0,\n \"size\": 10\n}"')
};
fetch('https://api.sophra.org/api/cortex/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/search",
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('"{\\n \\"index\\": \\"{{test_index_name}}\\",\\n \\"searchType\\": \\"hybrid\\",\\n \\"textQuery\\": {\\n \\"query\\": \\"{{search_query}}\\",\\n \\"fields\\": [\\"title\\", \\"content\\"],\\n \\"operator\\": \\"AND\\"\\n },\\n \\"vectorQuery\\": {\\n \\"vector\\": [{{test_doc_embeddings}}],\\n \\"field\\": \\"embeddings\\",\\n \\"k\\": 2\\n },\\n \\"boost\\": {\\n \\"text\\": 0.4,\\n \\"vector\\": 0.2\\n },\\n \\"from\\": 0,\\n \\"size\\": 10\\n}"'),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/search"
payload := strings.NewReader("\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/search")
.header("Content-Type", "*/*")
.body("\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "\"\\\"{\\\\n \\\\\\\"index\\\\\\\": \\\\\\\"{{test_index_name}}\\\\\\\",\\\\n \\\\\\\"searchType\\\\\\\": \\\\\\\"hybrid\\\\\\\",\\\\n \\\\\\\"textQuery\\\\\\\": {\\\\n \\\\\\\"query\\\\\\\": \\\\\\\"{{search_query}}\\\\\\\",\\\\n \\\\\\\"fields\\\\\\\": [\\\\\\\"title\\\\\\\", \\\\\\\"content\\\\\\\"],\\\\n \\\\\\\"operator\\\\\\\": \\\\\\\"AND\\\\\\\"\\\\n },\\\\n \\\\\\\"vectorQuery\\\\\\\": {\\\\n \\\\\\\"vector\\\\\\\": [{{test_doc_embeddings}}],\\\\n \\\\\\\"field\\\\\\\": \\\\\\\"embeddings\\\\\\\",\\\\n \\\\\\\"k\\\\\\\": 2\\\\n },\\\\n \\\\\\\"boost\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": 0.4,\\\\n \\\\\\\"vector\\\\\\\": 0.2\\\\n },\\\\n \\\\\\\"from\\\\\\\": 0,\\\\n \\\\\\\"size\\\\\\\": 10\\\\n}\\\"\""
response = http.request(request)
puts response.read_bodyHeaders
Body
*/*
The body is of type string.
Example:
"\"{\\n \\\"index\\\": \\\"{{test_index_name}}\\\",\\n \\\"searchType\\\": \\\"hybrid\\\",\\n \\\"textQuery\\\": {\\n \\\"query\\\": \\\"{{search_query}}\\\",\\n \\\"fields\\\": [\\\"title\\\", \\\"content\\\"],\\n \\\"operator\\\": \\\"AND\\\"\\n },\\n \\\"vectorQuery\\\": {\\n \\\"vector\\\": [{{test_doc_embeddings}}],\\n \\\"field\\\": \\\"embeddings\\\",\\n \\\"k\\\": 2\\n },\\n \\\"boost\\\": {\\n \\\"text\\\": 0.4,\\n \\\"vector\\\": 0.2\\n },\\n \\\"from\\\": 0,\\n \\\"size\\\": 10\\n}\""
Response
200 - application/json
Successful response

