// In common/proto/search2.proto
syntax = "proto3";
package komp_ac.search2;

service Search2 {
    rpc SearchTable(Search2Request) returns (Search2Response);
}

message Search2Request {
  string profile_name = 1;
  string table_name = 2;
  repeated ColumnFilter column_filters = 3;
  optional string text_query = 4;  // Optional fallback text search
  optional int32 limit = 5;
  optional string order_by = 6;
  optional bool order_desc = 7;
}

message ColumnFilter {
    string column_name = 1;
    FilterType filter_type = 2;
    string value = 3;
    optional string value2 = 4;  // For range queries
}

enum FilterType {
    EQUALS = 0;
    CONTAINS = 1;
    STARTS_WITH = 2;
    ENDS_WITH = 3;
    RANGE = 4;
    GREATER_THAN = 5;
    LESS_THAN = 6;
    IS_NULL = 7;
    IS_NOT_NULL = 8;
}

message Search2Response {
    message Hit {
        int64 id = 1;
        string content_json = 2;  // No score - this is SQL-based
        optional string match_info = 3;  // Info about which columns matched
    }
    repeated Hit hits = 1;
    int32 total_count = 2;  // Total matching records (for pagination)
}
