<i id='wuoPo'><tr id='wuoPo'><dt id='wuoPo'><q id='wuoPo'><span id='wuoPo'><b id='wuoPo'><form id='wuoPo'><ins id='wuoPo'></ins><ul id='wuoPo'></ul><sub id='wuoPo'></sub></form><legend id='wuoPo'></legend><bdo id='wuoPo'><pre id='wuoPo'><center id='wuoPo'></center></pre></bdo></b><th id='wuoPo'></th></span></q></dt></tr></i><div id='wuoPo'><tfoot id='wuoPo'></tfoot><dl id='wuoPo'><fieldset id='wuoPo'></fieldset></dl></div>
    1. <legend id='wuoPo'><style id='wuoPo'><dir id='wuoPo'><q id='wuoPo'></q></dir></style></legend><tfoot id='wuoPo'></tfoot>
      • <bdo id='wuoPo'></bdo><ul id='wuoPo'></ul>

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

      1. 如何在 Lucene 中进行多字段 - 短语搜索?

        时间:2023-09-29

              <tfoot id='ql4Tr'></tfoot>
              <i id='ql4Tr'><tr id='ql4Tr'><dt id='ql4Tr'><q id='ql4Tr'><span id='ql4Tr'><b id='ql4Tr'><form id='ql4Tr'><ins id='ql4Tr'></ins><ul id='ql4Tr'></ul><sub id='ql4Tr'></sub></form><legend id='ql4Tr'></legend><bdo id='ql4Tr'><pre id='ql4Tr'><center id='ql4Tr'></center></pre></bdo></b><th id='ql4Tr'></th></span></q></dt></tr></i><div id='ql4Tr'><tfoot id='ql4Tr'></tfoot><dl id='ql4Tr'><fieldset id='ql4Tr'></fieldset></dl></div>
                <tbody id='ql4Tr'></tbody>
                <bdo id='ql4Tr'></bdo><ul id='ql4Tr'></ul>
                <legend id='ql4Tr'><style id='ql4Tr'><dir id='ql4Tr'><q id='ql4Tr'></q></dir></style></legend>
                • <small id='ql4Tr'></small><noframes id='ql4Tr'>

                • 本文介绍了如何在 Lucene 中进行多字段 - 短语搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  标题问一切...我想在 Lucene 中进行多字段短语搜索.. 怎么做?

                  Title asks it all... I want to do a multi field - phrase search in Lucene.. How to do it ?

                  例如:我的字段为 String s[] = {"title","author","content"};
                  我想在所有领域搜索 harry potter.我该怎么做?

                  for example : I have fields as String s[] = {"title","author","content"};
                  I want to search harry potter across all fields.. How do I do it ?

                  有人可以提供一个示例片段吗?

                  Can someone please provide an example snippet ?

                  推荐答案

                  1. 使用 MultiFieldQueryParser,它的 一个 QueryParser 构造查询以搜索多个字段..

                  其他方法是使用创建一个由 TermQurey 组成的 BooleanQuery(在您的情况下是短语查询).

                  Other way is to use Create a BooleanQuery consisting of TermQurey (in your case phrase query).

                  第三种方法是将其他字段的内容包含到您的 default 内容字段中.

                  Third way is to include the content of other fields into your default content field.

                  <小时>添加

                  一般来说,查询多个字段并不是用户输入查询的最佳做法.更常见的是,您想要搜索的所有单词都通过组合各种字段被索引到内容或关键字字段中.<小时>更新

                  Generally speaking, querying on multiple fields isn’t the best practice for user-entered queries. More commonly, all words you want searched are indexed into a contents or keywords field by combining various fields.


                  Update

                  用法:

                  Query query = MultiFieldQueryParser.parse(Version.LUCENE_30, new String[] {"harry potter","harry potter","harry potter"},   new String[] {"title","author","content"},new SimpleAnalyzer());
                  IndexSearcher searcher = new IndexSearcher(...);
                  Hits hits = searcher.search(query);
                  

                  MultiFieldQueryParser 将以这种方式解析查询:(参见 javadoc)

                  The MultiFieldQueryParser will resolve the query in this way: (See javadoc)

                  解析在指定的字段.如果 x 字段是指定,这有效构造:

                  Parses a query which searches on the fields specified. If x fields are specified, this effectively constructs:

                  (field1:query1) (field2:query2)(field3:query3)...(fieldx:queryx)

                  (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)

                  希望这会有所帮助.

                  这篇关于如何在 Lucene 中进行多字段 - 短语搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java 线程在处理结束时变慢 下一篇:有谁知道如何使用带有 Lucene 3.6 的 Wordnet 扩展查

                  相关文章

                  最新文章

                • <legend id='3xEmu'><style id='3xEmu'><dir id='3xEmu'><q id='3xEmu'></q></dir></style></legend>

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

                  <small id='3xEmu'></small><noframes id='3xEmu'>

                    <bdo id='3xEmu'></bdo><ul id='3xEmu'></ul>
                      <tfoot id='3xEmu'></tfoot>