<small id='iZuOf'></small><noframes id='iZuOf'>

    <i id='iZuOf'><tr id='iZuOf'><dt id='iZuOf'><q id='iZuOf'><span id='iZuOf'><b id='iZuOf'><form id='iZuOf'><ins id='iZuOf'></ins><ul id='iZuOf'></ul><sub id='iZuOf'></sub></form><legend id='iZuOf'></legend><bdo id='iZuOf'><pre id='iZuOf'><center id='iZuOf'></center></pre></bdo></b><th id='iZuOf'></th></span></q></dt></tr></i><div id='iZuOf'><tfoot id='iZuOf'></tfoot><dl id='iZuOf'><fieldset id='iZuOf'></fieldset></dl></div>
    <tfoot id='iZuOf'></tfoot>

  1. <legend id='iZuOf'><style id='iZuOf'><dir id='iZuOf'><q id='iZuOf'></q></dir></style></legend>
      <bdo id='iZuOf'></bdo><ul id='iZuOf'></ul>

      lucene 在查询中获得匹配的术语

      lucene get matched terms in query(lucene 在查询中获得匹配的术语)
      <legend id='MMc5N'><style id='MMc5N'><dir id='MMc5N'><q id='MMc5N'></q></dir></style></legend>

        <small id='MMc5N'></small><noframes id='MMc5N'>

            <bdo id='MMc5N'></bdo><ul id='MMc5N'></ul>

            <tfoot id='MMc5N'></tfoot>
              <i id='MMc5N'><tr id='MMc5N'><dt id='MMc5N'><q id='MMc5N'><span id='MMc5N'><b id='MMc5N'><form id='MMc5N'><ins id='MMc5N'></ins><ul id='MMc5N'></ul><sub id='MMc5N'></sub></form><legend id='MMc5N'></legend><bdo id='MMc5N'><pre id='MMc5N'><center id='MMc5N'></center></pre></bdo></b><th id='MMc5N'></th></span></q></dt></tr></i><div id='MMc5N'><tfoot id='MMc5N'></tfoot><dl id='MMc5N'><fieldset id='MMc5N'></fieldset></dl></div>
                  <tbody id='MMc5N'></tbody>
              1. 本文介绍了lucene 在查询中获得匹配的术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 lucene 中找出与给定文档匹配的查询中的哪些词的最佳方法是什么?

                What is the best way to find out which terms in a query matched against a given document returned as a hit in lucene?

                我尝试了一种奇怪的方法,涉及 lucene contrib 中的命中突出显示包,以及一种针对最顶层文档搜索查询中每个单词的方法(docId: xy AND description: each_word_in_query").

                I have tried a weird method involving hit highlighting package in lucene contrib and also a method that searches for every word in the query against the top most document ("docId: xy AND description: each_word_in_query").

                没有得到满意的结果?命中突出显示不报告与第一个文档以外的文档匹配的某些单词.我不确定第二种方法是否是最佳选择.

                Do not get satisfactory results? Hit highlighting does not report some of the words that matched for a document other than the first one. I'm not sure if the second approach is the best alternative.

                推荐答案

                方法explain 在 Searcher 中是查看查询的哪个部分匹配以及如何匹配的好方法它会影响总分.

                The method explain in the Searcher is a nice way to see which part of a query was matched and how it affects the overall score.

                示例取自《Lucene In Action 2nd Edition》一书:

                Example taken from the book Lucene In Action 2nd Edition:

                public class Explainer {
                
                  public static void main(String[] args) throws Exception {
                
                     if (args.length != 2) {
                        System.err.println("Usage: Explainer <index dir> <query>");
                        System.exit(1);
                     }
                
                     String indexDir = args[0];
                     String queryExpression = args[1];
                     Directory directory = FSDirectory.open(new File(indexDir));
                     QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,
                                                     "contents", new SimpleAnalyzer());
                
                     Query query = parser.parse(queryExpression);
                     System.out.println("Query: " + queryExpression);
                     IndexSearcher searcher = new IndexSearcher(directory);
                     TopDocs topDocs = searcher.search(query, 10);
                     for (int i = 0; i < topDocs.totalHits; i++) {
                        ScoreDoc match = topDocs.scoreDocs[i];
                        Explanation explanation = searcher.explain(query, match.doc);   
                        System.out.println("----------");
                        Document doc = searcher.doc(match.doc);
                        System.out.println(doc.get("title"));
                        System.out.println(explanation.toString());
                     }
                  }
                }
                

                这将解释与查询匹配的每个文档的分数.

                This will explain the score of each document that matches the query.

                这篇关于lucene 在查询中获得匹配的术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)
                • <legend id='u76Ts'><style id='u76Ts'><dir id='u76Ts'><q id='u76Ts'></q></dir></style></legend>
                  <i id='u76Ts'><tr id='u76Ts'><dt id='u76Ts'><q id='u76Ts'><span id='u76Ts'><b id='u76Ts'><form id='u76Ts'><ins id='u76Ts'></ins><ul id='u76Ts'></ul><sub id='u76Ts'></sub></form><legend id='u76Ts'></legend><bdo id='u76Ts'><pre id='u76Ts'><center id='u76Ts'></center></pre></bdo></b><th id='u76Ts'></th></span></q></dt></tr></i><div id='u76Ts'><tfoot id='u76Ts'></tfoot><dl id='u76Ts'><fieldset id='u76Ts'></fieldset></dl></div>

                  <small id='u76Ts'></small><noframes id='u76Ts'>

                    <tbody id='u76Ts'></tbody>

                      <tfoot id='u76Ts'></tfoot>
                        <bdo id='u76Ts'></bdo><ul id='u76Ts'></ul>