Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Solr Atomic update with incremental popularity

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 422
    Comment on it

    In solr we can create a field which can update as the related doc is searched by user.

    For that we need to add a field in schema.xml as:

    <field name="popularity" type="long" indexed="true" stored="true"/>

    In the below code we have used a map which takes the incremented value with the option(inc - incremental), this will always increment the field by the defined value, in this case by a value of 1.

    SolrInputDocument doc = new SolrInputDocument();
    Map<String, Object> partialUpdate = new HashMap<String, Object>();
    partialUpdate.put("inc", new Integer(1));// keep increasing the value by 1
    doc.addField("id", id);
    doc.addField("popularity", partialUpdate);
    server.add(doc);
    server.commit();

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: