Building a Lexical Search Query
Describes how to build and run a Lexical Search query.
Lexical Search, or Classic Search, is a fundamental approach to retrieve information based on keyword, integer, float, date etc. value matching. This search operates by assessing the similarity of a collection documents to a query document. It then selects the documents with the top scores and return their id's to the user.
Running the Lexical (Classic) Search Query in DSL Syntax
query = {
"query": {
"bool": {
"must": [
{"term": {"name": "John"}}
]
}
}
}
results = hyperspace_client.dsl_search(query,
size=10,
collection_name=collection_name)
Where query is your query logic, see example below.
query = {
"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
}
}
}
Last updated