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

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

      <tfoot id='gtXoc'></tfoot>

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

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

      1. solrj:如何存储和检索List&lt;POJO&gt;通过索引中的多值字段

        solrj: how to store and retrieve Listlt;POJOgt; via multivalued field in index(solrj:如何存储和检索Listlt;POJOgt;通过索引中的多值字段)
      2. <legend id='OFgxk'><style id='OFgxk'><dir id='OFgxk'><q id='OFgxk'></q></dir></style></legend>

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

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

                  <tfoot id='OFgxk'></tfoot>
                    <tbody id='OFgxk'></tbody>
                  本文介绍了solrj:如何存储和检索List&lt;POJO&gt;通过索引中的多值字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的用例是一个包含在线媒体标题的索引.数据的提供者将类别列表与每个标题相关联.我正在使用 SolrJ 通过带注释的 POJO 类填充索引

                  My use case is an index which holds titles of online media. The provider of the data associates a list of categories with each title. I am using SolrJ to populate the index via an annotated POJO class

                  例如

                  @Field("title")
                  private String title;
                  
                  @Field("categories")
                  private List<Category> categoryList;
                  

                  关联的 POJO 是

                  public class Category {
                      private Long id;
                      private String name;
                  ...
                  

                  }

                  我的问题分为两部分:

                  a) 这可以通过 SolrJ 实现吗 - 文档仅包含使用字符串列表的 @Field 示例,因此我假设序列化/编组仅支持简单类型?

                  a) is this possible via SolrJ - the docs only contain an example of @Field using a List of String, so I assume the serialization/marshalling only supports simple types ?

                  b) 我将如何设置架构来保存它.我有一个天真的假设,我只需要设置multiValued=true 在必填字段 &一切都会变魔术.

                  b) how would I set up the schema to hold this. I have a naive assumption I just need to set multiValued=true on the required field & it will all work by magic.

                  我刚刚开始实施此功能,因此我们将不胜感激.

                  I'm just starting to implement this so any response would be highly appreciated.

                  推荐答案

                  答案如你所想:

                  a) 你只有简单的类型可用.因此,您将拥有一个相同类型的列表,例如细绳.关键是你不能在 lucene 文档中表示复杂的类型,所以你也不会反序列化它们.

                  a) You have only simple types available. So you will have a List of the same type e.g. String. The point is you cant represent complex types inside the lucene document so you wont deserialize them as well.

                  b) 问题是您正在尝试在文档存储"中表示关系思维.这可能只会在一定程度上起作用.如果您想在 lucene 文档中表示类别,只需使用字符串即可,也不必存储 id.

                  b) The problem is what you are trying is to represent relational thinking in a "document store". That will probably work only to a certain point. If you want to represent categories inside a lucene document just use the string it is not necessary to store a id as well.

                  同时存储 id 的唯一一点是:如果您想抛开搜索,请在 RDBMS 上进行查找.如果你想这样做,你需要确保 id 和类别名称是软链接的.这不适用于每个 1:n 关系.(每一个 n 相关表只包含必填字段的 1:n 关系都是可能的.如果您有一个可选字段,您需要尽可能在该字段中放置类似填充的空常量).

                  The only point to store an id as well is: if you want to do aside the search a lookup on a RDBMS. If you want to do this you need to make sure that the id and the category name is softlinked. This is not working for every 1:n relation. (Every 1:n relation where the n related table consists only of required fields is possible. If you have an optional field you need to put something like a filling emptyconstant in the field if possible).

                  但是,如果这些 1:n 关系不是稀疏的,那么实际上如果您保持将字段添加到文档的顺序,那么它实际上是可能的.因此,如果您不对列表进行排序,则可能可以表示具有类别关系的情况.

                  However if these 1:n relations are not sparse its possible actually if you maintain the order in which you add fields to the document. So the case with the category relation can be probably represented if you dont sort the lists.

                  如果你用位置 0...n 的值实例化它,你可以实现一个返回这个 Category 的方法.因此,解决方案是,如果您想要第一个类别,它将位于与该类别相关的每个列表的位置 0.

                  You may implement a method which returns this Category if you instantiate it with the values at position 0...n. So the solution would be if you want to have the first category it will be at position 0 of every list related to this category.

                  这篇关于solrj:如何存储和检索List&lt;POJO&gt;通过索引中的多值字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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如何按不区分大小写进行搜索)

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

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

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