mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:29:32 -05:00 
			
		
		
		
	chore(server): simplify search face query and better clustering (#5573)
* chore(server): simplify search face query and better clustering * update sql * Use correct syntax for utilizing the index * Update sql
This commit is contained in:
		
							parent
							
								
									2234394aa6
								
							
						
					
					
						commit
						f206cb9403
					
				@ -88,7 +88,7 @@ export class SmartInfoRepository implements ISmartInfoRepository {
 | 
				
			|||||||
        .select('1 + (faces.embedding <=> :embedding)', 'distance')
 | 
					        .select('1 + (faces.embedding <=> :embedding)', 'distance')
 | 
				
			||||||
        .innerJoin('faces.asset', 'asset')
 | 
					        .innerJoin('faces.asset', 'asset')
 | 
				
			||||||
        .where('asset.ownerId = :ownerId')
 | 
					        .where('asset.ownerId = :ownerId')
 | 
				
			||||||
        .orderBy(`faces.embedding <=> :embedding`)
 | 
					        .orderBy('1 + (faces.embedding <=> :embedding)')
 | 
				
			||||||
        .setParameters({ ownerId, embedding: asVector(embedding) })
 | 
					        .setParameters({ ownerId, embedding: asVector(embedding) })
 | 
				
			||||||
        .limit(numResults);
 | 
					        .limit(numResults);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -98,7 +98,7 @@ WITH
 | 
				
			|||||||
    WHERE
 | 
					    WHERE
 | 
				
			||||||
      "asset"."ownerId" = $2
 | 
					      "asset"."ownerId" = $2
 | 
				
			||||||
    ORDER BY
 | 
					    ORDER BY
 | 
				
			||||||
      "faces"."embedding" <= > $3 ASC
 | 
					      1 + ("faces"."embedding" <= > $3) ASC
 | 
				
			||||||
    LIMIT
 | 
					    LIMIT
 | 
				
			||||||
      100
 | 
					      100
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user