【问题标题】:is it possible in java-lucene to map multifield values?java-lucene 中是否可以映射多字段值?
【发布时间】:2011-11-27 14:07:10
【问题描述】:

我在 lucene 索引中有一个包含多个字段的文档,并且其中一些字段是多值的,例如

Document{ field1: field2: field3: .... field9:}

字段就像

field1:some string value
field2:some int value
.
.
.
field8:(string values that are space separated and each is a token )//uid for some items
field9:(value or items whose uid is in field8 and both field8 and field9 are one to one map)

有了这个,我可以在平面文档结构中搜索和索引一个多值字段,现在我有另一个字段,比如field10:其中我有多个值针对field8 中的单个 uid,那么我该如何索引并使用 lucene 在这个结构中搜索这个新字段

例如,我想索引并将 field10 值映射到 field8

field8: {     uid1    | uid2     | uid3} 
field10:{id1,id2,id3  | id1,id7  | id1 }

需要帮助 问候

【问题讨论】:

    标签: search lucene indexing


    【解决方案1】:

    这就是我认为您要问的问题。假设您有这样的文档:

    field8:  {    1    |    2    |    3    }
    field10: { foo,bar | baz,foo | bar,baz }
    

    您希望查询 +field8:1 +field10:foo 返回此文档,但 +field8:3 +field10:foo 不应返回该文档。

    这是一个关系数据模型,并不是 Lucene 试图擅长的。最好的选择是使用关系数据库。

    如果您想坚持使用 Lucene,您应该将这些字段中的每一个拆分到自己的文档中。因此,一个文档将是field8:1, field10: foo,bar 等。或者,您可以拥有自己的标记器,它使用有效负载或术语位置来处理此问题。我不知道它会特别容易或快速。

    本网站上有很多关于您的问题的问题,例如Storing relational data in a Lucene.NET index

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      • 2021-08-27
      • 1970-01-01
      相关资源
      最近更新 更多