2011-04-27 14:32



i have an lucene index with an "uniqueKey"


As far as i know, this key have to be "text" (not int or long).

<field name="ID" type="string" indexed="true" stored="true"/>

An small application used the lucene index in order to search only in those records, which are added since the last run of that application.

To reach that goal, i'm trying the following.

  1. Load the last ID (from flatfile) into the variable $oldID
  2. get the current (last/highest) ID from Solr/lucene into the variable $currentID
  3. execute an range search between $oldID and $currentID
  4. Save the $currentID into a flat file for next Search/for next run

Unfortunately I notice a problem:

A.) how to find the highest ID?

or B.) how i handle the unique key as an digit, not text/char

I tried something like that:


...which returns strange thinks: "999999" as the highest value. That's not correct, because the highest ID is 1043725. I think this is because ID is an Text-Field

C.) maybe there is any other way to search only at the last added recoreds?

Thanks for any kind of help!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • du2229 du2229 10年前

    Solr's uniqueKey field can support any of the data type classes that Solr supports. While the underlying Lucene index itself treats all stored/indexed data as text, Solr manages the translation to treat the indexed data according to data types.

    The string field-type restriction you're referring to is if you have enabled the QueryElevationComponent in solr config. If you have not enabled that feature, you can make your uniqueKey a long to solve your issue.

    点赞 评论 复制链接分享