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

      <tfoot id='oJOjr'></tfoot>
      • <bdo id='oJOjr'></bdo><ul id='oJOjr'></ul>

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

        Lucene 中的关键字(OR、AND)搜索

        Keyword (OR, AND) search in Lucene(Lucene 中的关键字(OR、AND)搜索)
          <tfoot id='vN3Ra'></tfoot>
          <legend id='vN3Ra'><style id='vN3Ra'><dir id='vN3Ra'><q id='vN3Ra'></q></dir></style></legend>

            <tbody id='vN3Ra'></tbody>

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

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

                  本文介绍了Lucene 中的关键字(OR、AND)搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的门户(基于 J2EE)中使用 Lucene 来提供索引和搜索服务.

                  问题在于 Lucene 的关键字.当您在搜索查询中使用其中一个时,您会收到错误消息.

                  例如:

                  searchTerms = "ik OR jij"

                  这很好用,因为它会搜索 "ik""jij"

                  searchTerms = "ik AND jij"

                  这很好用,它搜索 "ik""jij"

                  但是当你搜索时:

                  searchTerms = "OR"searchTerms = "AND"searchTerms = "ik 或"searchTerms = "或 ik"

                  等等,会失败并报错:

                  <上一页>组件名称:STSE_RESULTS 类:org.apache.lucene.queryParser.ParseException 消息:无法解析OR jij":在第 1 行第 0 列遇到OR".期待其中之一:...

                  这是有道理的,因为这些词是 Lucene 的关键字,可能是保留的,并将充当关键字.

                  在荷兰语中,OR"这个词很重要,因为它具有Ondernemings Raad"的含义.它在许多文本中使用,需要找到它.例如,或"确实有效,但不返回与或"一词匹配的文本.如何使其可搜索?

                  如何转义关键字或"?或者我如何告诉 Lucene 将或"视为搜索词而不是关键字.

                  解决方案

                  我猜你试过把OR"放在双引号里?

                  如果这不起作用,我认为您可能不得不更改 Lucene 源代码,然后重新编译整个东西,因为运算符OR"深埋在代码中.实际上,编译可能还不够:您必须更改源包中用作 JavaCC 输入的文件 QueryParser.jj,然后运行 JavaCC,然后重新编译整个东西.

                  不过,好消息是只有一行需要更改:

                  <代码>|<OR: ("OR" | "||") >

                  变成

                  <代码>|<OR: ("||") >

                  这样,您将只有||"作为逻辑或运算符.有一个 build.xml 也包含 JavaCC 的调用,但你必须下载 那个工具你自己.恐怕我现在不能自己尝试.

                  这对于 Lucene 开发者邮件列表来说可能是一个很好的问题,但是如果你这样做了,请告诉我们,他们会提出一个更简单的解决方案 ;-)

                  I am using Lucene in my portal (J2EE based) for indexing and search services.

                  The problem is about the keywords of Lucene. When you use one of them in the search query, you'll get an error.

                  For example:

                  searchTerms = "ik OR jij"
                  

                  This works fine, because it will search for "ik" or "jij"

                  searchTerms = "ik AND jij"
                  

                  This works fine, it searches for "ik" and "jij"

                  But when you search:

                  searchTerms = "OR"
                  searchTerms = "AND"
                  searchTerms = "ik OR"
                  searchTerms = "OR ik"
                  

                  Etc., it will fail with an error:

                  Component Name: STSE_RESULTS  Class: org.apache.lucene.queryParser.ParseException  Message: Cannot parse 'OR jij': Encountered "OR" at line 1, column 0. 
                  Was expecting one of: 
                  ... 
                  

                  It makes sense, because these words are keywords for Lucene are probably reserved and will act as keywords.

                  In Dutch, the word "OR" is important because it has a meaning for "Ondernemings Raad". It is used in many texts, and it needs to be found. For example "or" does work, but does not return texts matching the term "OR". How can I make it searchable?

                  How can I escape the keyword "or"? Or How can I tell Lucene to treat "or" as a search term NOT as a keyword.

                  解决方案

                  I suppose you have tried putting the "OR" into double quotes?

                  If that doesn't work I think you might have to go so far as to change the Lucene source and then recompile the whole thing, as the operator "OR" is buried deep inside the code. Actually, compiling probably isn't even enough: you'll have to change the file QueryParser.jj in the source package that serves as input for JavaCC, then run JavaCC, then recompile the whole thing.

                  The good news, however, is that there's only one line to change:

                  | <OR: ("OR" | "||") >

                  becomes

                  | <OR: ("||") >

                  That way, you'll have only "||" as logical OR operator. There is a build.xml that also contains the invocation of JavaCC, but you have to download that tool yourself. I can't try it myself right now, I'm afraid.

                  This is perhaps a good question for the Lucene developer mailing list, but please let us know if you do that and they come up with a simpler solution ;-)

                  这篇关于Lucene 中的关键字(OR、AND)搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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如何按不区分大小写进行搜索)
                      <tbody id='Hpj6G'></tbody>
                    <tfoot id='Hpj6G'></tfoot>
                      <bdo id='Hpj6G'></bdo><ul id='Hpj6G'></ul>
                    • <i id='Hpj6G'><tr id='Hpj6G'><dt id='Hpj6G'><q id='Hpj6G'><span id='Hpj6G'><b id='Hpj6G'><form id='Hpj6G'><ins id='Hpj6G'></ins><ul id='Hpj6G'></ul><sub id='Hpj6G'></sub></form><legend id='Hpj6G'></legend><bdo id='Hpj6G'><pre id='Hpj6G'><center id='Hpj6G'></center></pre></bdo></b><th id='Hpj6G'></th></span></q></dt></tr></i><div id='Hpj6G'><tfoot id='Hpj6G'></tfoot><dl id='Hpj6G'><fieldset id='Hpj6G'></fieldset></dl></div>

                        • <legend id='Hpj6G'><style id='Hpj6G'><dir id='Hpj6G'><q id='Hpj6G'></q></dir></style></legend>

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