search via tantivy on different grpc port works perfectly well now
This commit is contained in:
@@ -2,14 +2,16 @@
|
||||
|
||||
use std::path::Path;
|
||||
use tantivy::{collector::TopDocs, query::QueryParser, Index, TantivyDocument};
|
||||
use tantivy::schema::Value;
|
||||
use tonic::{transport::Server, Request, Response, Status};
|
||||
use tonic_reflection::server::Builder as ReflectionBuilder;
|
||||
use common::proto::multieko2::FILE_DESCRIPTOR_SET;
|
||||
|
||||
use common::proto::multieko2::search::{
|
||||
search_response::Hit,
|
||||
searcher_server::{Searcher, SearcherServer},
|
||||
SearchRequest, SearchResponse,
|
||||
};
|
||||
use tantivy::schema::Value;
|
||||
|
||||
pub struct SearcherService;
|
||||
|
||||
@@ -84,7 +86,6 @@ impl Searcher for SearcherService {
|
||||
// Convert results to our response format
|
||||
let mut hits = Vec::new();
|
||||
for (score, doc_address) in top_docs {
|
||||
// FIX: Add explicit type TantivyDocument for the retrieved doc
|
||||
let doc: TantivyDocument = searcher.doc(doc_address).map_err(
|
||||
|e| {
|
||||
Status::internal(format!(
|
||||
@@ -94,7 +95,6 @@ impl Searcher for SearcherService {
|
||||
},
|
||||
)?;
|
||||
|
||||
// Extract the PostgreSQL ID from the document
|
||||
if let Some(pg_id_value) = doc.get_first(pg_id_field) {
|
||||
if let Some(pg_id) = pg_id_value.as_u64() {
|
||||
hits.push(Hit {
|
||||
@@ -116,10 +116,15 @@ pub async fn run_search_service(
|
||||
let addr = addr.parse()?;
|
||||
let searcher_service = SearcherService;
|
||||
|
||||
let reflection_service = ReflectionBuilder::configure()
|
||||
.register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET)
|
||||
.build_v1()?;
|
||||
|
||||
println!("Search service listening on {}", addr);
|
||||
|
||||
Server::builder()
|
||||
.add_service(SearcherServer::new(searcher_service))
|
||||
.add_service(reflection_service)
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user