Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-39057

Add distance expressions for image feature comparison

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      This ticket tracks the work contained in Pull Request #1291.

      We added these expressions:

      '$cossim', '$chi2', '$euclidean', '$squared_euclidean', '$manhattan'

      Which allow us to compare long vectors (image features) stored as arrays or BSON.
      It is useful to find the most similar images in a dataset. The usage is the following:

      db.test_speed.aggregate([
          {   
              '$project':
              {
                  'id': '$id',
                  "other_id": '$other_id',
                  'distance': {'$cossim': [vector, '$vector']},
              },
          },
          {"$sort": {"distance": -1}},
          {"$limit": 20}
      ])
      

      In addition implementations using avx2 and avx512 are included in this pull request.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Votes:
            1 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated: