mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 08:44:27 +01:00
Construct the documents based on the displayed fields or fields ids order
This commit is contained in:
parent
303c3ce89e
commit
9b08f48dbd
@ -1,11 +1,12 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs::{File, create_dir_all};
|
use std::fs::{File, create_dir_all};
|
||||||
use std::{mem, io};
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
use std::{mem, io};
|
||||||
|
|
||||||
use askama_warp::Template;
|
use askama_warp::Template;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
@ -440,9 +441,14 @@ pub fn run(opt: Opt) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let mut documents = Vec::new();
|
let mut documents = Vec::new();
|
||||||
let fields_ids_map = index.fields_ids_map(&rtxn).unwrap();
|
let fields_ids_map = index.fields_ids_map(&rtxn).unwrap();
|
||||||
|
let displayed_fields = match index.displayed_fields(&rtxn).unwrap() {
|
||||||
|
Some(fields) => Cow::Borrowed(fields),
|
||||||
|
None => Cow::Owned(fields_ids_map.iter().map(|(id, _)| id).collect()),
|
||||||
|
};
|
||||||
|
|
||||||
for (_id, record) in index.documents(&rtxn, documents_ids).unwrap() {
|
for (_id, record) in index.documents(&rtxn, documents_ids).unwrap() {
|
||||||
let mut record = record.iter()
|
let mut record = displayed_fields.iter()
|
||||||
|
.flat_map(|&id| record.get(id).map(|val| (id, val)))
|
||||||
.map(|(key_id, value)| {
|
.map(|(key_id, value)| {
|
||||||
let key = fields_ids_map.name(key_id).unwrap().to_owned();
|
let key = fields_ids_map.name(key_id).unwrap().to_owned();
|
||||||
// TODO we must deserialize a Json Value and highlight it.
|
// TODO we must deserialize a Json Value and highlight it.
|
||||||
|
Loading…
Reference in New Issue
Block a user