Question

I have some articles in Solr and I show their details in my web application.

I've defined a SearchHandler in solrconfig.xml:

 <requestHandler name="/getbyid" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <str name="wt">json</str>
      <str name="indent">true</str>
      <str name="qf">id</str>
      <str name="df">id</str>
      <str name="mm">100%</str>
      <str name="rows">1</str>
      <str name="fl">*,score</str>
    </lst>
  </requestHandler>

When user clicks on a document to see the detail, I extract data using this handler.

I've defined a field in schema.xml:

<field name="viewCount" type="int" indexed="false" stored="true" multiValued="false" />

When users clicks, I get the document using the handler, then I update the document with incremented viewCount.

Is there any built-in solution in Solr to implement the view count of a document?

If not, what is the best way to update the viewCount? (I should update viewCount and commit the document each time the users want to see it)

Was it helpful?

Solution

You can't update automatically during fetching data. The best solution I know, is to create batch xml commands and then POST the xml batch file to SOLR server in specific intervals. Also, there are some new features in SOLR 4 like increment which could be useful in you scenario.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top