2011-04-27 14:32
浏览 52


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!

图片转代码服务由CSDN问答提供 功能建议


   &lt; uniqueKey&gt; ID&lt; / uniqueKey&gt; 


 &lt; field name =“ID”type =“string”indexed =“true”stored =“true”/&gt; 
 \  n 


为了达到这个目标,我是 尝试以下操作。

  1. 加载最后一个ID(从flatfile) 到变量$ oldID
  2. 获取当前(最后/最高) )ID 从Solr / lucene到变量 $ currentID
  3. 在 $ oldID和$ currentID之间执行范围搜索
  4. 将$ currentID保存到 平面文件 下一个搜索/下次运行


    A。)如何查找 最高的身份证?

    或B.)我如何处理作为数字的唯一键,而不是text / char


     <代码>的http://本地主机:8080 / solr的/选择/ DEFTYPE = FUNC&安培; q = MAX(ID,0)及FQ = ID:[$ OLDID + TO + $ currentID]安培 ; fl = ID 

    ...返回奇怪的想法:“999999”为最高值。 这是不正确的,因为最高ID是1043725.我认为这是因为ID是文本字段

    C。)也许还有其他方法只搜索最后添加的recoreds ?


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • du2229 2011-04-28 06:08

    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题