简体   繁体   English

Solr-如何加权多值字段的字段条目?

[英]Solr - How to weight field entries of a multivalued field?

I store categories in documents which should be weighted in the documents itself, eg Restaurant - 0.5 (= 50%), Bar - 0.25, Music - 0.25. 我将类别存储在应在文档本身中加权的文档中,例如,餐厅-0.5(= 50%),酒吧-0.25,音乐-0.25。 Unfortunately I'm new to solr and don't really know to which feature in solr it could belong. 不幸的是,我是solr的新手,并不真正知道solr可能属于哪个功能。

The documents look like this: 这些文档如下所示:

    <str name="id">C1</str>
    <str name="name">Wine</str>
    <str name="type">Compass</str>
    <str name="geo">51.049842,13.740707</str>
    <double name="radius">5.0</double>
    <arr name="cat">
      <str>Restaurant</str>
      <str>Restaurant</str>
      <str>Bar</str>
      <str>Music</str>
    </arr>

How could I query the expected weitght? 我如何查询预期的重量? Is there an other way than store similar entries? 除了存储类似条目,还有其他方法吗?

You can achieve this with Payload feature of Solr/Lucene. 您可以使用Solr / Lucene的有效负载功能来实现。 Getting Started with Payloads will give you the general idea. 有效负载入门将为您提供总体思路。 Your document with payloads will look like: 具有有效负载的文档将如下所示:

<str name="id">C1</str>
<str name="name">Wine</str>
<str name="type">Compass</str>
<str name="geo">51.049842,13.740707</str>
<double name="radius">5.0</double>
<arr name="cat">
  <str>Restaurant|50</str>
  <str>Bar|25</str>
  <str>Music|25</str>
</arr>

After you indexed the document you can have a custom score for your document, that can be based only on payloads or on a combination with lucene default span score. 将文档编入索引后,您可以为文档自定义分数,该分数只能基于有效载荷或基于Lucene默认跨度分数的组合。

You can find more examples of payload query usage in lucene-solr/tests . 您可以在lucene-solr / tests中找到更多有关有效负载查询用法的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM