File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -46,18 +46,16 @@ def index
4646 end
4747 end
4848
49- # Apply text search after basic filtering to work on smaller dataset
50-
51- # Apply similarity search on already filtered dataset
52- if params [ :similar_to ] . present?
49+ # Contains should take priority and we shouldn't do similarity and contains
50+ if params [ :contains ] . present?
51+ @documents = @documents . smart_search ( params [ :contains ] )
52+ elsif params [ :similar_to ] . present?
5353 embedding = get_embedding ( params [ :similar_to ] )
5454 # Get similar documents but preserve existing filters
5555 @documents = @documents . related_by_embedding ( embedding )
5656
5757 # Sort by neighbor_distance using SQL to maintain ActiveRecord relation
5858 @documents = @documents . order ( 'neighbor_distance ASC' )
59- elsif params [ :contains ] . present?
60- @documents = @documents . smart_search ( params [ :contains ] )
6159 else
6260 # Only apply default sorting if not doing similarity search
6361 @documents = if params [ :sort ] == 'questions'
You can’t perform that action at this time.
0 commit comments