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

    2. <tfoot id='ET92g'></tfoot>

      1. <small id='ET92g'></small><noframes id='ET92g'>

        Lucene - 检索文档中多值字段的所有值

        时间:2023-09-29

        <legend id='F14Mc'><style id='F14Mc'><dir id='F14Mc'><q id='F14Mc'></q></dir></style></legend>

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

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

                <tbody id='F14Mc'></tbody>
                  <tfoot id='F14Mc'></tfoot>

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

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

                  问题描述

                  我在 Lucene 中添加了一个多值字段:

                  I added a field in Lucene which is multi-valued as such:

                  String categoriesForItem = getCategories(); // returns "category1, category2, cat3" from a DB call
                  
                  String [] categoriesForItems = categoriesForItem.split(","; 
                  for(String cat : categoriesForItems) {
                      doc.add(new StringField("categories", cat , Field.Store.YES)); // doc is a Document 
                  }
                  

                  稍后当我在某个类别中搜索项目时,一切都按预期工作,但是当我得到一个文档并执行以下操作时:

                  later when I am searching for items in a category everything works as expected, but when I get a Document and do:

                  String categories= doc.getField("categories").stringValue(); 
                  

                  我只获取该文档的最后插入值,而不是为该文档添加的所有值.

                  I only get the last inserted value for that document rather than all the values that were added for that document.

                  如何获取为该文档添加的所有值?

                  How can I get all the values which were added for that document?

                  推荐答案

                  你添加到文档中的不是多值单字段,而是多个同名字段.最后,您只检索一个字段.

                  What you are adding to the document is not multi-valued single field, but multiple fields with the same name. At the end you are only retrieving one field.

                  使用 public final ListDocument 的 getFields() 代替.

                  Use public final List<IndexableField> getFields() of Document instead.

                  这篇关于Lucene - 检索文档中多值字段的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Lucene 索引和搜索同时进行 下一篇:Lucene 4.0 中的词频

                  相关文章

                  最新文章

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

                  1. <legend id='YBmEN'><style id='YBmEN'><dir id='YBmEN'><q id='YBmEN'></q></dir></style></legend>

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

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