Configuring and Using Similarity Measures

The #attrsimilar function calculates similarity between a given vector and vectors in the index. For example, you can use it to detect 3D parts with similar shape or size.

#attrsimilar is a query node in the index, which returns all the documents matching the similarity query and calculates the similarity measure. As it does not filter search results at all, you must combine it with a #filter to return only the documents having a similarity higher than a given threshold value.

Note: Similarity is the inverse of distance and calculated as follows: similarity = 1 - distance
Important: The standard way to use #attrsimilar is inside a query template. See Defining Query Templates.


In this section:

Configure the Index for Similarity Queries
Use the #attrsimilar Function in the Search API
Code Samples to Create Similarity Query Prefix Handlers