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

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

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

  • <tfoot id='mAEFP'></tfoot>

      1. “-"的 Lucene 索引问题特点

        时间:2023-09-29

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

            <small id='1Rmp4'></small><noframes id='1Rmp4'>

              <tbody id='1Rmp4'></tbody>
              1. <tfoot id='1Rmp4'></tfoot>

                <legend id='1Rmp4'><style id='1Rmp4'><dir id='1Rmp4'><q id='1Rmp4'></q></dir></style></legend>
                • <bdo id='1Rmp4'></bdo><ul id='1Rmp4'></ul>
                  本文介绍了“-"的 Lucene 索引问题特点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在使用 Lucene 索引时遇到问题,该索引的索引词包含-"字符.

                  I'm having trouble with a Lucene Index, which has indexed words, that contain "-" Characters.

                  它适用于某些包含-"的单词,但不适用于所有单词,我找不到原因,为什么它不起作用.

                  It works for some words that contain "-" but not for all and I don't find the reason, why it's not working.

                  我正在搜索的字段经过分析并包含带有和不带有-"字符的单词的版本.

                  The field I'm searching in, is analyzed and contains version of the word with and without the "-" character.

                  我正在使用分析器:org.apache.lucene.analysis.standard.StandardAnalyzer

                  I'm using the analyzer: org.apache.lucene.analysis.standard.StandardAnalyzer

                  这里是一个例子:

                  如果我搜索gsx-*"我得到一个结果,索引字段包含铃木 GSX-R 1000 GSX-R1000 GSXR"

                  if I search for "gsx-*" I got a result, the indexed field contains "SUZUKI GSX-R 1000 GSX-R1000 GSXR"

                  但如果我搜索v-*",我没有得到任何结果.预期结果的索引字段包含:铃木 DL 1000 V-STROM DL1000V-STROMVSTROM V STROM"

                  but if I search for "v-*" I got no result. The indexed field of the expected result contains: "SUZUKI DL 1000 V-STROM DL1000V-STROMVSTROM V STROM"

                  如果我在没有*"的情况下搜索v-strom",它可以工作,但如果我只搜索v-str",例如我不会得到结果.(应该有结果,因为它是针对网上商店的实时搜索)

                  If I search for "v-strom" without "*" it works, but if I just search for "v-str" for example I don't get the result. (There should be a result because it's for a live search for a webshop)

                  那么,两个预期结果之间有什么区别?为什么它适用于gsx-"而不适用于v-"?

                  So, what's the difference between the 2 expected results? why does it work for "gsx-" but not for "v-" ?

                  推荐答案

                  我相信,StandardAnalyzer 会将连字符视为空格.所以它把你的查询 "gsx-*" 变成 "gsx*""v-*" 变成空,因为 at 也消除了单字母令牌.您在搜索结果中看到的字段内容是该字段的存储值,它完全独立于为该字段编制索引的术语.

                  StandardAnalyzer will treat the hyphen as whitespace, I believe. So it turns your query "gsx-*" into "gsx*" and "v-*" into nothing because at also eliminates single-letter tokens. What you see as the field contents in the search result is the stored value of the field, which is completely independent of the terms that were indexed for that field.

                  所以你想要的是将v-strom"作为一个整体作为一个索引词.StandardAnalyzer 不适合这种文本.也许可以试试 WhitespaceAnalyzerSimpleAnalyzer.如果这仍然不能解决问题,您还可以选择将自己的分析器放在一起,或者只是从这两个开始并使用进一步的 TokenFilters 组合它们.theLucene 分析包 Javadoc.

                  So what you want is for "v-strom" as a whole to be an indexed term. StandardAnalyzer is not suited to this kind of text. Maybe have a go with the WhitespaceAnalyzer or SimpleAnalyzer. If that still doesn't cut it, you also have the option of throwing together your own analyzer, or just starting off those two mentined and composing them with further TokenFilters. A very good explanation is given in the Lucene Analysis package Javadoc.

                  顺便说一句,不需要在索引中输入所有变体,例如 V-strom、V-Strom 等.这个想法是让同一个分析器在索引中和解析时将所有这些变体标准化为相同的字符串查询.

                  BTW there's no need to enter all the variants in the index, like V-strom, V-Strom, etc. The idea is for the same analyzer to normalize all these variants to the same string both in the index and while parsing the query.

                  这篇关于“-"的 Lucene 索引问题特点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Lucene不是空查询? 下一篇:Lucene 作为数据存储

                  相关文章

                  最新文章

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

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

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