Hybrid Search Using Vector and Scalar Field

By specifying a Boolean expression, users can filter the scalar field of the entities during the vector search. Hippo will only return the results that match the filter condition. Scalar field indexing is an excellent way of improving the performance and accuracy rate of hybrid search.

curl -u shiva:shiva -XGET 'localhost:8902/hippo/v1/{table}/_search?pretty' -H 'Content-Type: application/json' -d'{
  "output_fields": ["book_id"],
  "search_params": {
    "anns_field": "book_intro",
    "topk": 2,
    "params": {
      "k_factor" : 100
    }
  },
  "vectors": [ [0.1,0.2], [0.3, 0.4] ],
  "dsl": "word_count >= 11000",
  "only_explain" : false
}';

Result:

{
  "num_queries" : 2,
  "top_k" : 2,
  "results" : [
    {
      "query" : 0,
      "fields_data" : [
        {
          "field_name" : "book_id",
          "field_values" : [11,12]
        }
      ],
      "scores" : [119.44999,142.24998]
    },
    {
      "query" : 1,
      "fields_data" : [
        {
          "field_name" : "book_id",
          "field_values" : [11,12]
        }
      ],
      "scores" : [114.85,137.25]
    }
  ]
}

Parameter description:

ParametersDescriptionRequired
tableTable name, such as "book" created in this exampleYes
database_nameDatabase where the table is locatedNo, defaults to "default" database
output_fieldsName of the field to returnYes
anns_fieldName of the field to search onYes
topkThe number of records to returnYes
paramsSearch parameter specific to vector indexNo
embedding_indexVector index used in current searchNo, uses the first activated vector index built on the field specified in "anns_field" by default
vectorsQuery vectorYes
dslScalar filter conditionYes
only_explainWhether to execute "explain" onlyNo, defaults to false
Table 36 Hybrid Search (Restful API)

Hybrid Search Using Array and Vector Fields

This chapter introduces how to conduct hybrid search using indexed array and vector fields. Regarding how to create array index, please refer to Create Array Index.

curl -u shiva:shiva -XGET 'localhost:8902/hippo/v1/book/_search?database_name={database_name}&pretty' -H'Content-Type: application/json' -d'{
  "output_fields": ["book_id"],
  "search_params": {
    "anns_field": "book_intro",
    "topk": 10
  },
  "vectors": [ [0.1,0.2], [0.3, 0.4] ],
  "dsl": "attributes in [attr5, attr8, attr9]"
}';

Result:

{
  "num_queries" : 2,
  "top_k" : 10,
  "results" : [
    {
      "query" : 0,
      "fields_data" : [
        {
          "field_name" : "book_id",
          "field_values" : [21,22,23,24,25,26,27,28,29,30],
          "scores" : [437.45,480.25,525.05,571.85,620.65,671.45,724.25,779.05,835.85,894.64996]
        }
      ]
    },
    {
      "query" : 1,
      "fields_data" : [
        {
          "field_name" : "book_id",
          "field_values" : [21,22,23,24,25,26,27,28,29,30],
          "scores" : [428.85,471.25003,515.65,562.05005,610.45,660.85004,713.25,767.65,824.05005,882.45]
        }
      ]
    }
  ]
}