当前位置: 首页 > news >正文

网站后台系统使用小程序模板与定制开发的区别

网站后台系统使用,小程序模板与定制开发的区别,现在有哪些免费推广平台,免费天眼查在 Apache Lucene 中#xff0c;Field 类是文档中存储数据的基础。不同类型的 Field 用于存储不同类型的数据#xff08;如文本、数字、二进制数据等#xff09;。以下是一些常用的 Field 类型及其底层存储结构#xff1a; TextField#xff1a; 用途#xff1a;用于存储… 在 Apache Lucene 中Field 类是文档中存储数据的基础。不同类型的 Field 用于存储不同类型的数据如文本、数字、二进制数据等。以下是一些常用的 Field 类型及其底层存储结构 TextField 用途用于存储文本数据并对其进行分词和索引。底层存储结构文本数据会被分词器Analyzer处理将文本分割成词项terms。每个词项会被存储在倒排索引inverted index中映射到包含该词项的文档。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.TextField; import org.apache.lucene.document.Field.Store;Document doc new Document(); doc.add(new TextField(fieldName, This is a sample text., Store.YES)); StringField 用途用于存储不需要分词的字符串数据如唯一标识符ID等。底层存储结构字符串数据作为一个整体存储在倒排索引中不会进行分词。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.StringField; import org.apache.lucene.document.Field.Store;Document doc new Document(); doc.add(new StringField(fieldName, unique_identifier, Store.YES)); IntPoint、LongPoint、FloatPoint、DoublePoint 用途用于存储数值数据并支持范围查询。底层存储结构数值数据会被转换成字节数组并按照分块block的方式存储以支持高效的范围查询。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.IntPoint; import org.apache.lucene.document.StoredField;Document doc new Document(); int value 123; doc.add(new IntPoint(fieldName, value)); doc.add(new StoredField(fieldName, value)); // 如果需要存储原始值 StoredField 用途用于存储不需要索引的数据仅用于检索时返回的字段。底层存储结构数据以原始字节的形式存储在存储字段stored field中不会被索引。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.StoredField;Document doc new Document(); doc.add(new StoredField(fieldName, This is the stored content.)); BinaryField 用途用于存储二进制数据。底层存储结构二进制数据以原始字节的形式存储在存储字段中不会被索引。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.StoredField; import org.apache.lucene.util.BytesRef;Document doc new Document(); byte[] byteArray new byte[] {1, 2, 3, 4, 5}; doc.add(new StoredField(fieldName, new BytesRef(byteArray))); SortedDocValuesField 和 NumericDocValuesField 用途用于存储排序和打分时需要的字段值。底层存储结构数据以紧凑的格式存储在文档值doc values中支持高效的排序和打分计算。示例 import org.apache.lucene.document.Document; import org.apache.lucene.document.SortedDocValuesField; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.util.BytesRef;Document doc new Document(); doc.add(new SortedDocValuesField(fieldName, new BytesRef(sortable value))); doc.add(new NumericDocValuesField(numericField, 12345L));lucene检索打分原理 在 Apache Lucene 中打分Scoring是指在搜索过程中根据文档与查询的匹配程度为每个文档分配一个相关性分数relevance score。这个分数反映了文档与查询的相关性分数越高表示文档越相关。打分用于确定搜索结果的排序即哪些文档应该排在前面展示给用户。 打分的基本概念 相关性分数 每个文档在搜索结果中都会有一个相关性分数数值越高表示文档越符合查询条件。相关性分数是一个浮点数通常在 0 到 1 之间但也可以大于 1。 TF-IDF 模型 Lucene 使用 TF-IDFTerm Frequency-Inverse Document Frequency模型来计算相关性分数。TF词频在一个文档中某个词的出现频率。词频越高表示该词对文档的重要性越大。IDF逆文档频率某个词在所有文档中出现的频率。文档频率越低表示该词对区分文档的重要性越大。 BM25 算法 BM25 是 Lucene 默认的打分算法是 TF-IDF 的进化版本能够更好地处理长查询和长文档。BM25 考虑了词频、逆文档频率、文档长度等因素。 import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory;public class LuceneScoringExample {public static void main(String[] args) throws Exception {// 创建分析器StandardAnalyzer analyzer new StandardAnalyzer();// 创建索引Directory index new RAMDirectory();IndexWriterConfig config new IndexWriterConfig(analyzer);IndexWriter writer new IndexWriter(index, config);// 添加文档addDoc(writer, Lucene in Action, 193398817);addDoc(writer, Lucene for Dummies, 55320055Z);addDoc(writer, Managing Gigabytes, 55063554A);addDoc(writer, The Art of Computer Science, 9900333X);writer.close();// 创建查询String querystr Lucene;// 解析查询Query query new QueryParser(title, analyzer).parse(querystr);// 搜索int hitsPerPage 10;IndexSearcher searcher new IndexSearcher(DirectoryReader.open(index));TopDocs docs searcher.search(query, hitsPerPage);ScoreDoc[] hits docs.scoreDocs;// 显示结果System.out.println(Found hits.length hits.);for (int i 0; i hits.length; i) {int docId hits[i].doc;Document d searcher.doc(docId);System.out.println((i 1) . d.get(isbn) \t d.get(title) \t hits[i].score);}}private static void addDoc(IndexWriter w, String title, String isbn) throws Exception {Document doc new Document();doc.add(new TextField(title, title, Field.Store.YES));doc.add(new StringField(isbn, isbn, Field.Store.YES));w.addDocument(doc);} } 在 Apache Lucene 中打分scoring是一个动态计算的过程相关性分数并不是预先存储在索引中的而是根据查询和文档在搜索时实时计算的。因此打分的值是临时的不会永久存储在索引中。 动态计算 当你执行一个查询时Lucene 会根据查询条件和文档内容动态计算每个匹配文档的相关性分数。这个计算过程基于查询的类型、词频TF、逆文档频率IDF、文档长度等因素。 不存储在索引中 相关性分数并不会被存储在索引中。存储在索引中的信息包括倒排索引、词项频率、文档值等。每次执行查询时Lucene 都会重新计算相关性分数这确保了分数总是根据最新的查询条件和文档内容而更新。
http://www.hkea.cn/news/14493452/

相关文章:

  • 佛山网站建设找方维网络郑州seo招聘
  • app公司网站模板如何用腾讯云建设自己网站
  • 怎样用c语言做网站简单几步为wordpress加上留言板
  • 网站建设维护公司资质黄埔做网站的公
  • dede做的网站总被挂马简易php企业网站源码
  • 国内网站设计经典案例泰安的网络建设公司
  • 制作小公司网站一般多少钱我的学校网页怎么制作
  • 网站使用问题哪些网站用c 做的
  • 佛山正规网站建设报价编程猫少儿编程官网
  • 渭南市住房和城乡建设局网站十堰网站建设电话
  • 凡科二级网站怎么做网站源码 带后台
  • 网站优化内链怎么做软件开发项目管理工具
  • 公司注册网站需要什么条件网站流量导入是什么意思
  • 和各大网站做视频的工作总结天津购物网站搭建
  • 网站品质cpancel面板搭建WordPress
  • 微信后台网站开发知识体系贵阳网站建设 设计可以吗
  • 网站企业业务员怎么做网站开发者工具
  • 微软的网站开发软件wordpress英文版中文版
  • 做网站 哪里发布温泉网站建设
  • 2014做社交网站网站建设算什么专业
  • 通河县机场建设网站产品设计大师作品
  • 红河公司 网站建设wordpress调用目录
  • 建设局查询网站首页网站建设的步骤及方法
  • 湖州网站制作报价自己做视频直播网站
  • 钟村免费建站公司建筑工程信息价哪里可以查询
  • 成都市微信网站建设报价前端开发培训学费
  • 仿网站百度会怎么做网站开发成本主要有哪些
  • 泰安网站建设入门网站设计模板源码
  • 网站建设方案范文8篇云朵课堂网站开发怎么收费
  • 东营免费网站制作智能小程序是什么