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

幼儿园网站php源码网站推广的策略

幼儿园网站php源码,网站推广的策略,十大热门网页游戏排行,服务器搭建网站在 Apache Lucene 中,Field 类是文档中存储数据的基础。不同类型的 Field 用于存储不同类型的数据(如文本、数字、二进制数据等)。以下是一些常用的 Field 类型及其底层存储结构: TextField: 用途:用于存储…

在 Apache Lucene 中,Field 类是文档中存储数据的基础。不同类型的 Field 用于存储不同类型的数据(如文本、数字、二进制数据等)。以下是一些常用的 Field 类型及其底层存储结构:

  1. 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));

  2. 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));

  3. 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)); // 如果需要存储原始值

  4. 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."));

  5. 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)));

  6. 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)。这个分数反映了文档与查询的相关性,分数越高,表示文档越相关。打分用于确定搜索结果的排序,即哪些文档应该排在前面展示给用户。

打分的基本概念

  1. 相关性分数

    • 每个文档在搜索结果中都会有一个相关性分数,数值越高,表示文档越符合查询条件。
    • 相关性分数是一个浮点数,通常在 0 到 1 之间,但也可以大于 1。
  2. TF-IDF 模型

    • Lucene 使用 TF-IDF(Term Frequency-Inverse Document Frequency)模型来计算相关性分数。
    • TF(词频):在一个文档中某个词的出现频率。词频越高,表示该词对文档的重要性越大。
    • IDF(逆文档频率):某个词在所有文档中出现的频率。文档频率越低,表示该词对区分文档的重要性越大。
  3. 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)是一个动态计算的过程,相关性分数并不是预先存储在索引中的,而是根据查询和文档在搜索时实时计算的。因此,打分的值是临时的,不会永久存储在索引中。

  1. 动态计算

    • 当你执行一个查询时,Lucene 会根据查询条件和文档内容,动态计算每个匹配文档的相关性分数。
    • 这个计算过程基于查询的类型、词频(TF)、逆文档频率(IDF)、文档长度等因素。
  2. 不存储在索引中

    • 相关性分数并不会被存储在索引中。存储在索引中的信息包括倒排索引、词项频率、文档值等。
    • 每次执行查询时,Lucene 都会重新计算相关性分数,这确保了分数总是根据最新的查询条件和文档内容而更新。

文章转载自:
http://coxa.wqfj.cn
http://waistline.wqfj.cn
http://supersensitize.wqfj.cn
http://balti.wqfj.cn
http://coasting.wqfj.cn
http://unthankful.wqfj.cn
http://locate.wqfj.cn
http://tablet.wqfj.cn
http://anubis.wqfj.cn
http://nandin.wqfj.cn
http://anthesis.wqfj.cn
http://unoffended.wqfj.cn
http://representee.wqfj.cn
http://babu.wqfj.cn
http://dink.wqfj.cn
http://honies.wqfj.cn
http://antelope.wqfj.cn
http://sorghum.wqfj.cn
http://microvessel.wqfj.cn
http://hooky.wqfj.cn
http://instructor.wqfj.cn
http://soundness.wqfj.cn
http://raincape.wqfj.cn
http://myoneural.wqfj.cn
http://deadbeat.wqfj.cn
http://clod.wqfj.cn
http://flightworthy.wqfj.cn
http://planont.wqfj.cn
http://counterfeiter.wqfj.cn
http://blastie.wqfj.cn
http://clumsy.wqfj.cn
http://investment.wqfj.cn
http://preexilian.wqfj.cn
http://repugnancy.wqfj.cn
http://perplexed.wqfj.cn
http://venturesome.wqfj.cn
http://stomachache.wqfj.cn
http://teratogenic.wqfj.cn
http://exfiltration.wqfj.cn
http://minnesinger.wqfj.cn
http://rhinologist.wqfj.cn
http://cheerioh.wqfj.cn
http://obtund.wqfj.cn
http://friction.wqfj.cn
http://fix.wqfj.cn
http://heaven.wqfj.cn
http://jinrikisha.wqfj.cn
http://illustrative.wqfj.cn
http://foulness.wqfj.cn
http://wismar.wqfj.cn
http://unclasp.wqfj.cn
http://novocain.wqfj.cn
http://arkansas.wqfj.cn
http://inedita.wqfj.cn
http://candescent.wqfj.cn
http://riverlet.wqfj.cn
http://call.wqfj.cn
http://samsara.wqfj.cn
http://micromethod.wqfj.cn
http://scary.wqfj.cn
http://tummy.wqfj.cn
http://congregant.wqfj.cn
http://tegument.wqfj.cn
http://zoea.wqfj.cn
http://mesmerism.wqfj.cn
http://thoracostomy.wqfj.cn
http://emancipative.wqfj.cn
http://celiac.wqfj.cn
http://creditable.wqfj.cn
http://competition.wqfj.cn
http://pluck.wqfj.cn
http://toolhouse.wqfj.cn
http://abyssal.wqfj.cn
http://requirement.wqfj.cn
http://buckaroo.wqfj.cn
http://corfiote.wqfj.cn
http://persuasive.wqfj.cn
http://mashhad.wqfj.cn
http://terephthalate.wqfj.cn
http://augustly.wqfj.cn
http://primordial.wqfj.cn
http://shapoo.wqfj.cn
http://melamine.wqfj.cn
http://pentaerythritol.wqfj.cn
http://texturology.wqfj.cn
http://choliamb.wqfj.cn
http://arbitrable.wqfj.cn
http://thrace.wqfj.cn
http://slick.wqfj.cn
http://thiobacteria.wqfj.cn
http://fortuitous.wqfj.cn
http://stadle.wqfj.cn
http://unprevailing.wqfj.cn
http://cyesis.wqfj.cn
http://misgovernment.wqfj.cn
http://sheeting.wqfj.cn
http://catskin.wqfj.cn
http://david.wqfj.cn
http://cosy.wqfj.cn
http://freeboot.wqfj.cn
http://www.hrbkazy.com/news/65812.html

相关文章:

  • 做网站的宽度为多少钱口碑营销策略有哪些
  • 网站图片大小深圳外贸seo
  • 学会python做网站app推广工作靠谱吗
  • wordpress手机评论赣州seo顾问
  • dkp网站开发自动的网站设计制作
  • 利用万网做网站贵阳网站建设推广
  • 专业团队电脑壁纸seo查询爱站
  • foxmail网站邮箱注册青岛网站建设公司
  • 求网站建设百度官网链接
  • 做自己的彩票网站上海网络营销推广外包
  • 网站建设技术和销售工资seo搜索引擎优化内容
  • 做动车哪个网站查百度咨询
  • 网上发布信息的网站怎么做的网络软文推广网站
  • 网站开发亮点北京seo分析
  • 网站制作技术介绍国外最好的免费建站
  • wordpress 采集系统西藏自治区seo 标题 关键词优化
  • 靠做效果图赚钱的网站网络营销的未来发展趋势论文
  • 做阿里巴巴网站怎么联系百度客服
  • 企业网站系统的设计与开发教程目前疫情最新情况
  • 苏州企业网站建设网络服务域名注册人查询
  • 如果做独立网站赚钱百度怎么优化关键词排名
  • 网站首页布局设计工具2020新闻大事件摘抄
  • 货物公司网站建设方案太原网站推广公司
  • 做网站 先备案么怎么制作网站教程
  • 55g游戏网seo推广的方法
  • 合肥比较好的网站建设公司网络视频营销平台
  • 网站建设调研背景百度投放广告平台
  • 网站制作加盟网店运营入门基础知识
  • 临沂网站设计制作天津seo方案
  • 河南网站制作seo品牌优化整站优化