Do not insert fields in the map when changing the settings

This commit is contained in:
Kerollmops 2021-07-22 17:11:17 +02:00
parent aa02a7fdd8
commit 7aa6cc9b04
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
6 changed files with 46 additions and 96 deletions

View file

@ -8,7 +8,7 @@ use heed::types::*;
use heed::{Database, PolyDatabase, RoTxn, RwTxn};
use roaring::RoaringBitmap;
use crate::error::{FieldIdMapMissingEntry, InternalError, UserError};
use crate::error::{InternalError, UserError};
use crate::fields_ids_map::FieldsIdsMap;
use crate::heed_codec::facet::{
FacetLevelValueF64Codec, FacetStringLevelZeroCodec, FacetStringLevelZeroValueCodec,
@ -353,15 +353,8 @@ impl Index {
let fields_ids_map = self.fields_ids_map(rtxn)?;
let mut fields_ids = Vec::new();
for name in fields.into_iter() {
match fields_ids_map.id(name) {
Some(field_id) => fields_ids.push(field_id),
None => {
return Err(FieldIdMapMissingEntry::FieldName {
field_name: name.to_string(),
process: "Index::displayed_fields_ids",
}
.into())
}
if let Some(field_id) = fields_ids_map.id(name) {
fields_ids.push(field_id);
}
}
Ok(Some(fields_ids))
@ -403,15 +396,8 @@ impl Index {
let fields_ids_map = self.fields_ids_map(rtxn)?;
let mut fields_ids = Vec::new();
for name in fields {
match fields_ids_map.id(name) {
Some(field_id) => fields_ids.push(field_id),
None => {
return Err(FieldIdMapMissingEntry::FieldName {
field_name: name.to_string(),
process: "Index::searchable_fields_ids",
}
.into())
}
if let Some(field_id) = fields_ids_map.id(name) {
fields_ids.push(field_id);
}
}
Ok(Some(fields_ids))
@ -451,17 +437,8 @@ impl Index {
let mut fields_ids = HashSet::new();
for name in fields {
match fields_ids_map.id(&name) {
Some(field_id) => {
fields_ids.insert(field_id);
}
None => {
return Err(FieldIdMapMissingEntry::FieldName {
field_name: name,
process: "Index::filterable_fields_ids",
}
.into())
}
if let Some(field_id) = fields_ids_map.id(&name) {
fields_ids.insert(field_id);
}
}
@ -498,17 +475,8 @@ impl Index {
let mut fields_ids = HashSet::new();
for name in fields.into_iter() {
match fields_ids_map.id(&name) {
Some(field_id) => {
fields_ids.insert(field_id);
}
None => {
return Err(FieldIdMapMissingEntry::FieldName {
field_name: name,
process: "Index::faceted_fields_ids",
}
.into())
}
if let Some(field_id) = fields_ids_map.id(&name) {
fields_ids.insert(field_id);
}
}