External File Field in Apache Solr

后端 未结 1 1361
灰色年华
灰色年华 2021-01-19 19:18

I\'ve been trying to use ExternalFileField in ApacheSolr for external scoring.

I\'m using the example config. Basically I want to set scores for items using their

相关标签:
1条回答
  • 2021-01-19 19:47

    Alright, so I had the same problem. This is what I did:

    1. Create a file:
      solr_home/PROJECT/multicore/core1/data/external_popularProducts.txt

      The file should contain values like this:
      uniqueID_in_core=count

      Example:
      873728721=19
      842728342=20

    2. Update schema.xml, add this under <types> </types>
      <fieldType name="popularProductsFile" keyField="key" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="float" />

      Here, key is the column name for the primaryID of solr core.
      Add this under <fields></fields>
      <field name="popularProducts" type="popularProductsFile" indexed="true" stored="true" />

    3. Reload the core. I am using solr4.3 which has a bug. When I try to reload any core,the solrcloud node goes down. SOLR-4805: SolrCloud - RELOAD on collections or cores leaves collection offline and unusable till restart . So, I had to restart my solrcloud nodes.

    4. Query: http://SOLR_NODE:8983/solr/core1/select?q=ipad&sort=popularProducts desc

    Note:
    Most of the blogs written about ExternalFileField are not completely accurate. So just refer to the original documentation:

    1. http://lucene.apache.org/solr/4_3_1/solr-core/org/apache/solr/schema/ExternalFileField.html .
    2. http://docs.lucidworks.com/display/solr/Working+with+External+Files+and+Processes

    Please improve this answer if you find any issues with it.

    0 讨论(0)
提交回复
热议问题