mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Replace hardcoded string with constants
This commit is contained in:
parent
fc23a0ee52
commit
44eb153619
26 changed files with 160 additions and 132 deletions
|
@ -4,6 +4,7 @@ use bumpalo::Bump;
|
|||
use hashbrown::HashMap;
|
||||
|
||||
use super::DelAddRoaringBitmap;
|
||||
use crate::constants::RESERVED_GEO_FIELD_NAME;
|
||||
use crate::update::new::channel::DocumentsSender;
|
||||
use crate::update::new::document::{write_to_obkv, Document as _};
|
||||
use crate::update::new::indexer::document_changes::{DocumentChangeContext, Extractor};
|
||||
|
@ -62,8 +63,10 @@ impl<'a, 'b, 'extractor> Extractor<'extractor> for DocumentsExtractor<'a, 'b> {
|
|||
context.index,
|
||||
&context.db_fields_ids_map,
|
||||
)?;
|
||||
let geo_iter =
|
||||
content.geo_field().transpose().map(|res| res.map(|rv| ("_geo", rv)));
|
||||
let geo_iter = content
|
||||
.geo_field()
|
||||
.transpose()
|
||||
.map(|res| res.map(|rv| (RESERVED_GEO_FIELD_NAME, rv)));
|
||||
for res in content.iter_top_level_fields().chain(geo_iter) {
|
||||
let (f, _) = res?;
|
||||
let entry = document_extractor_data
|
||||
|
@ -79,8 +82,10 @@ impl<'a, 'b, 'extractor> Extractor<'extractor> for DocumentsExtractor<'a, 'b> {
|
|||
let docid = update.docid();
|
||||
let content =
|
||||
update.current(&context.rtxn, context.index, &context.db_fields_ids_map)?;
|
||||
let geo_iter =
|
||||
content.geo_field().transpose().map(|res| res.map(|rv| ("_geo", rv)));
|
||||
let geo_iter = content
|
||||
.geo_field()
|
||||
.transpose()
|
||||
.map(|res| res.map(|rv| (RESERVED_GEO_FIELD_NAME, rv)));
|
||||
for res in content.iter_top_level_fields().chain(geo_iter) {
|
||||
let (f, _) = res?;
|
||||
let entry = document_extractor_data
|
||||
|
@ -90,8 +95,10 @@ impl<'a, 'b, 'extractor> Extractor<'extractor> for DocumentsExtractor<'a, 'b> {
|
|||
*entry -= 1;
|
||||
}
|
||||
let content = update.updated();
|
||||
let geo_iter =
|
||||
content.geo_field().transpose().map(|res| res.map(|rv| ("_geo", rv)));
|
||||
let geo_iter = content
|
||||
.geo_field()
|
||||
.transpose()
|
||||
.map(|res| res.map(|rv| (RESERVED_GEO_FIELD_NAME, rv)));
|
||||
for res in content.iter_top_level_fields().chain(geo_iter) {
|
||||
let (f, _) = res?;
|
||||
let entry = document_extractor_data
|
||||
|
@ -121,8 +128,10 @@ impl<'a, 'b, 'extractor> Extractor<'extractor> for DocumentsExtractor<'a, 'b> {
|
|||
DocumentChange::Insertion(insertion) => {
|
||||
let docid = insertion.docid();
|
||||
let content = insertion.inserted();
|
||||
let geo_iter =
|
||||
content.geo_field().transpose().map(|res| res.map(|rv| ("_geo", rv)));
|
||||
let geo_iter = content
|
||||
.geo_field()
|
||||
.transpose()
|
||||
.map(|res| res.map(|rv| (RESERVED_GEO_FIELD_NAME, rv)));
|
||||
for res in content.iter_top_level_fields().chain(geo_iter) {
|
||||
let (f, _) = res?;
|
||||
let entry = document_extractor_data
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use serde_json::Value;
|
||||
|
||||
use crate::constants::RESERVED_GEO_FIELD_NAME;
|
||||
use crate::update::new::document::Document;
|
||||
use crate::update::new::extract::geo::extract_geo_coordinates;
|
||||
use crate::update::new::extract::perm_json_p;
|
||||
|
@ -69,7 +70,7 @@ pub fn extract_document_facets<'doc>(
|
|||
}
|
||||
}
|
||||
|
||||
if attributes_to_extract.contains(&"_geo") {
|
||||
if attributes_to_extract.contains(&RESERVED_GEO_FIELD_NAME) {
|
||||
if let Some(geo_value) = document.geo_field()? {
|
||||
if let Some([lat, lng]) = extract_geo_coordinates(external_document_id, geo_value)? {
|
||||
let (lat_fid, lng_fid) = field_id_map
|
||||
|
|
|
@ -9,6 +9,7 @@ use heed::RoTxn;
|
|||
use serde_json::value::RawValue;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::constants::RESERVED_GEO_FIELD_NAME;
|
||||
use crate::error::GeoError;
|
||||
use crate::update::new::document::Document;
|
||||
use crate::update::new::indexer::document_changes::{DocumentChangeContext, Extractor};
|
||||
|
@ -28,8 +29,8 @@ impl GeoExtractor {
|
|||
index: &Index,
|
||||
grenad_parameters: GrenadParameters,
|
||||
) -> Result<Option<Self>> {
|
||||
let is_sortable = index.sortable_fields(rtxn)?.contains("_geo");
|
||||
let is_filterable = index.filterable_fields(rtxn)?.contains("_geo");
|
||||
let is_sortable = index.sortable_fields(rtxn)?.contains(RESERVED_GEO_FIELD_NAME);
|
||||
let is_filterable = index.filterable_fields(rtxn)?.contains(RESERVED_GEO_FIELD_NAME);
|
||||
if is_sortable || is_filterable {
|
||||
Ok(Some(GeoExtractor { grenad_parameters }))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue