unobtanium 3.0.0

Opinioated Web search engine library with crawler and viewer companion.
Documentation
use serde::{Serialize,Deserialize};

/// This struct stores weights that can be used for the bm25 weighting of
/// the `full_text_entity_index` table.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FullTextEntityWeights {
	title: f32,
	description: f32,
	text: f32,
	secondary_text: f32,
	big_headlines: f32,
	small_headlines: f32,
	code_text: f32,
	quote_text: f32,
}

impl FullTextEntityWeights {
	pub fn to_bm25_sql(&self) -> String {
		return format!(
			"bm25(full_text_entity_index, 0, 0, {}, {}, {}, {}, {}, {}, {}, {})",
			self.title,
			self.description,
			self.text,
			self.secondary_text,
			self.big_headlines - self.text,
			self.small_headlines - self.text,
			self.code_text - self.text,
			self.quote_text - self.text,
		);
	}
}

impl Default for FullTextEntityWeights {
	fn default() -> Self {
		Self {
			title: 5.0,
			description: 1.5,
			text: 1.0,
			secondary_text: 0.75,
			big_headlines: 5.0,
			small_headlines: 3.1,
			code_text: 1.2,
			quote_text: 1.0,
		}
	}
}