Skip to content

Commit 8bc3033

Browse files
committed
Do not recommend parametrized index
1 parent 9d3029c commit 8bc3033

1 file changed

Lines changed: 22 additions & 30 deletions

File tree

lib/collection/src/problems/unindexed_field.rs

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use http::{HeaderMap, HeaderValue, Method, Uri};
88
use issues::{Action, Code, ImmediateSolution, Issue, Solution};
99
use itertools::Itertools;
1010
use segment::common::operation_error::OperationError;
11-
use segment::data_types::index::IntegerIndexParams;
1211
use segment::index::query_optimization::rescore_formula::parsed_formula::VariableId;
1312
use segment::json_path::JsonPath;
1413
use segment::types::{
@@ -384,7 +383,10 @@ impl<'a> Extractor<'a> {
384383
let full_key = JsonPath::extend_or_new(nested_prefix, key);
385384

386385
if self.needs_index(&full_key, &required_index) {
387-
let schemas = required_index.into_iter().map(PayloadFieldSchema::from);
386+
let schemas = required_index
387+
.into_iter()
388+
.map(PayloadSchemaType::from)
389+
.map(PayloadFieldSchema::FieldType);
388390
self.unindexed_schema
389391
.entry(full_key)
390392
.or_default()
@@ -512,7 +514,10 @@ impl<'a> Extractor<'a> {
512514
}
513515

514516
if self.needs_index(&key, &required_index) {
515-
let schemas = required_index.into_iter().map(PayloadFieldSchema::from);
517+
let schemas = required_index
518+
.into_iter()
519+
.map(PayloadSchemaType::from)
520+
.map(PayloadFieldSchema::FieldType);
516521
self.unindexed_schema
517522
.entry(key)
518523
.or_default()
@@ -585,42 +590,29 @@ fn schema_capabilities(value: &PayloadFieldSchema) -> HashSet<FieldIndexType> {
585590
index_types
586591
}
587592

588-
impl From<FieldIndexType> for PayloadFieldSchema {
593+
impl From<FieldIndexType> for PayloadSchemaType {
589594
fn from(val: FieldIndexType) -> Self {
590595
match val {
591-
FieldIndexType::IntMatch => {
592-
let params = IntegerIndexParams {
593-
lookup: Some(true),
594-
..Default::default()
595-
};
596-
PayloadFieldSchema::FieldParams(PayloadSchemaParams::Integer(params))
597-
}
598-
FieldIndexType::IntRange => {
599-
let params = IntegerIndexParams {
600-
range: Some(true),
601-
..Default::default()
602-
};
603-
PayloadFieldSchema::FieldParams(PayloadSchemaParams::Integer(params))
604-
}
605-
FieldIndexType::KeywordMatch => {
606-
PayloadFieldSchema::FieldType(PayloadSchemaType::Keyword)
607-
}
608-
FieldIndexType::FloatRange => PayloadFieldSchema::FieldType(PayloadSchemaType::Float),
609-
FieldIndexType::Text => PayloadFieldSchema::FieldType(PayloadSchemaType::Text),
610-
FieldIndexType::BoolMatch => PayloadFieldSchema::FieldType(PayloadSchemaType::Bool),
611-
FieldIndexType::UuidMatch => PayloadFieldSchema::FieldType(PayloadSchemaType::Uuid),
612-
FieldIndexType::UuidRange => PayloadFieldSchema::FieldType(PayloadSchemaType::Uuid),
613-
FieldIndexType::DatetimeRange => {
614-
PayloadFieldSchema::FieldType(PayloadSchemaType::Datetime)
615-
}
616-
FieldIndexType::Geo => PayloadFieldSchema::FieldType(PayloadSchemaType::Geo),
596+
FieldIndexType::IntMatch => PayloadSchemaType::Integer,
597+
FieldIndexType::IntRange => PayloadSchemaType::Integer,
598+
FieldIndexType::KeywordMatch => PayloadSchemaType::Keyword,
599+
FieldIndexType::FloatRange => PayloadSchemaType::Float,
600+
FieldIndexType::Text => PayloadSchemaType::Text,
601+
FieldIndexType::BoolMatch => PayloadSchemaType::Bool,
602+
FieldIndexType::UuidMatch => PayloadSchemaType::Uuid,
603+
FieldIndexType::UuidRange => PayloadSchemaType::Uuid,
604+
FieldIndexType::DatetimeRange => PayloadSchemaType::Datetime,
605+
FieldIndexType::Geo => PayloadSchemaType::Geo,
617606
}
618607
}
619608
}
620609

621610
#[cfg(test)]
622611
mod tests {
612+
use segment::data_types::index::IntegerIndexParams;
613+
623614
use super::*;
615+
624616
#[test]
625617
fn integer_index_capacities() {
626618
let params = PayloadSchemaParams::Integer(IntegerIndexParams {

0 commit comments

Comments
 (0)