سؤال

I store categories in documents which should be weighted in the documents itself, e.g. Restaurant - 0.5 (= 50%), Bar - 0.25, Music - 0.25. Unfortunately I'm new to solr and don't really know to which feature in solr it could belong.

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. 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.

You can find more examples of payload query usage in lucene-solr/tests.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top