duandie0884 2011-04-27 14:32
浏览 52
已采纳

solr:查找最后/最高的唯一键和范围搜索

i have an lucene index with an "uniqueKey"

<uniqueKey>ID</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:

http://localhost:8080/solr/select/?defType=func&q=max(ID,0)&fq=ID:[$oldID+TO+$currentID]&fl=ID

...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!

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装