dsl_search
The function dsl_search(query_schema, size, function_name, collection_name)
runs search queries Iin DSL syntaxt inside a collection.
Input
query_schema – the DLS query object.
size – Specifies the number of results to return.
function_name – Specifies the scoring function to be used in the Classic Search query, as described in Step 1, Creating the Scoring Function.
collection_name – Specifies the Collection in which to search.
fields (optional) – Specifies the document fields to be returned with each result.
Example
query = {
"query": {
"bool": {
"must": [
{"term": {"name": "John"}}
]
}
}
}
results = hyperspace_client.dsl_search(query,
size=10,
collection_name=collection_name)
Where query_string is your query logic, see example below.
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"term": {
"genres": "genres_value"
}
},
{
"term": {
"adult": "adult_value"
}
},
{
"bool": {
"must_not": [
{
"term": {
"title": "title_value"
}
}
]
}
}
],
"should": [
{
"range": {
"rating": {
"gt": 7.0
}
}
}
]
}
},
"boost_mode": "multiply",
"boost": 2.0
}
}
}Response
A list of candidates, as shown in the example below
{ "candidates": 1, "similarity": [ { "document_id": "29", "score": 10.0, "fields": { "FirstSeenTime": 1506116398, "City": "Jakarta" } } ], "took_ms": 33.625 }
Last updated