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

      <bdo id='FDpqE'></bdo><ul id='FDpqE'></ul>
  2. <legend id='FDpqE'><style id='FDpqE'><dir id='FDpqE'><q id='FDpqE'></q></dir></style></legend>
    <tfoot id='FDpqE'></tfoot>

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

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

      Lucene - retrieve all values for a multi-valued field in a document(Lucene - 检索文档中多值字段的所有值)

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

                  <tbody id='JXPkK'></tbody>
                <legend id='JXPkK'><style id='JXPkK'><dir id='JXPkK'><q id='JXPkK'></q></dir></style></legend>
                <tfoot id='JXPkK'></tfoot>
                本文介绍了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 - 检索文档中多值字段的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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='QKNLf'></tbody>

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

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

                      <bdo id='QKNLf'></bdo><ul id='QKNLf'></ul>
                        <tfoot id='QKNLf'></tfoot>
                        • <legend id='QKNLf'><style id='QKNLf'><dir id='QKNLf'><q id='QKNLf'></q></dir></style></legend>