solrlucenesolr6

Issues in sorting using map function due to url size exceeding in SOLR


I have a data stored with my preferred colour in DB as : red,yellow,black..... suppose 20 colours, Now whenever I search using SOLR I want my results to be boosted on basis of my preferred colour? how can we do this.... I tried map function of SOLR but for so many preferred colours my solr url length increases considerably. is there any easier way to do that?


Solution

  • Split the value into separate tokens or pre-process it to a multi valued field, then use a boost query to boost any results that match your query.

    You can use a PatternTokenizer to split the field into separate tokens:

     <fieldType name="text_color" class="solr.TextField" positionIncrementGap="100">
       <analyzer>
         <tokenizer class="solr.PatternTokenizerFactory" pattern="," />
       </analyzer>
     </fieldType>
    
    <field name="color" type="text_color" indexed="true" stored="true" />
    

    .. and the boost it in your query, using (e)dismax:

     &bq=color:red^10