首页 \ 问答 \ Apache Solr用Pattern替换“前缀”(Apache Solr Replacing “Prefixes” with Pattern)

Apache Solr用Pattern替换“前缀”(Apache Solr Replacing “Prefixes” with Pattern)

这是设置。

  1. 从mysql中查询select NULLIF(id,'') as unID <continue with other things..>

  2. 在schema.xml中, <field name='unID' type='unIDType' index... />

  3. 同样在schema.xml中,

<fieldType name="unIDType" class="solr.TextField"> <analyzer> <tokenizer class="solr.PatternTokenizerFactory" pattern="^([AZ]{2})?([0-9]{5})$" group="2"/> </analyzer> </fieldType>

  1. 也在schema.xml中

<copyField source='unID' dest='_text_' />

========

结果:

来自mysql:

unID
ID00001
ID00002
ID00003
ID00004
.
.
.

规则是它总是以ID前缀并且总是5 digits

用户只想搜索00001并获得该记录的答案。

我的PatternTokenizerFactory有效。

如果我搜索unid:10001,我会得到ID10001的记录。

但我无法将其置于默认搜索字段,因为只查询q=10001不起作用。 q=unID:10001有效。

编辑1:我也试过了Pattern Filter Factory。 它也没用。

我认为问题是新值“00001”不是默认搜索字段,而是“ID00001”。

我读到分析完成后,他们都被标记为默认搜索字段。 可能是我读错了吗?

=======

谢谢。


This is the setup.

  1. querying from mysql select NULLIF(id,'') as unID <continue with other things..>

  2. In schema.xml, <field name='unID' type='unIDType' index... />

  3. Also in schema.xml,

<fieldType name="unIDType" class="solr.TextField"> <analyzer> <tokenizer class="solr.PatternTokenizerFactory" pattern="^([A-Z]{2})?([0-9]{5})$" group="2"/> </analyzer> </fieldType>

  1. Also in schema.xml

<copyField source='unID' dest='_text_' />

========

Results:

from mysql:

unID
ID00001
ID00002
ID00003
ID00004
.
.
.

The rule is that it will always prefix with ID and will always 5 digits.

The users want to search just 00001 and get the answer for that record.

My PatternTokenizerFactory works.

If I search unID:10001, I get the records for ID10001.

But I am having trouble putting it to default search field because just querying q=10001 does not work. q=unID:10001 works.

edit 1: I also tried the Pattern Filter Factory. It didn't work either.

I think the problem is the new value "00001" is not at default search field, but "ID00001" is.

I read that the analyzing is done after they are all marked as default search field. May be I read it wrong?

=======

Thanks.


原文:https://stackoverflow.com/questions/40142115
更新时间:2023-04-29 10:04

最满意答案

这似乎是iOS 5.x中的回归:它发生在5.0和5.1模拟器和5.1设备上,但不在4.3模拟器或4.3.2设备上。

它也特别是字符串绘图似乎被打破 - 如果您所做的只是字符串绘制(避免创建/销毁上下文的开销),崩溃几乎立即发生:

-(void)threadFunc:(UIFont *)font {
  @autoreleasepool {
    NSString *string = @" ";
    CGRect r = {{0,0},{50,50}};
    UIGraphicsBeginImageContextWithOptions(r.size, YES, 0);
    for(;;) {
      @autoreleasepool {
        [string drawAtPoint:r.origin withFont:font];
      }
    }
    UIGraphicsEndImageContext();
  }
}

-(void)startThreads
{
  UIFont * font = [UIFont systemFontOfSize:12];
  for (int i = 2; i--;)
  {
    [NSThread detachNewThreadSelector:@selector(threadFunc:) toTarget:self withObject:font];
  }
}

编辑:只在多核环境(即双核设备或模拟器,假设多核Mac)中“几乎是即时”。 否则,崩溃大约需要10-20分钟。 我没有双核iOS 4.x设备(唯一的可能性似乎是iPad 2),但单核设备在一个多小时后没有崩溃。

我已经向Apple提出了一个错误,如果它影响到你,我会鼓励你这样做。


This appears to be a regression in iOS 5.x: It happens on the 5.0 and 5.1 simulators and on a 5.1 device, but not on the 4.3 simulator or a 4.3.2 device.

It's also specifically the string drawing that seems to be broken — if all you do is string-drawing (avoiding the overhead of creating/destroying contexts), the crash happens nearly instantly:

-(void)threadFunc:(UIFont *)font {
  @autoreleasepool {
    NSString *string = @" ";
    CGRect r = {{0,0},{50,50}};
    UIGraphicsBeginImageContextWithOptions(r.size, YES, 0);
    for(;;) {
      @autoreleasepool {
        [string drawAtPoint:r.origin withFont:font];
      }
    }
    UIGraphicsEndImageContext();
  }
}

-(void)startThreads
{
  UIFont * font = [UIFont systemFontOfSize:12];
  for (int i = 2; i--;)
  {
    [NSThread detachNewThreadSelector:@selector(threadFunc:) toTarget:self withObject:font];
  }
}

EDIT: It is "nearly instant" only in multi-core environments (i.e. a dual-core device or the simulator, assuming a multi-core Mac). Otherwise, it takes on the order of 10-20 minutes to crash. I don't have a dual-core iOS 4.x device (the only possibility appears to be the iPad 2), but the single-core devices haven't crashed after over an hour.

I've raised a bug with Apple, and encourage you to do the same if it affects you.

相关问答

更多
  • 基于一些经验和基于各种文档的经验,我相信UIGraphicsPushContext()的文档是不正确的。 我相信UIGraphicsPushContext()实际上是线程安全的。 QA1637说明了这一点:“从iOS 4.0开始,在UIKit中绘制图形上下文是线程安全的,包括访问和操作当前图形堆栈 ,绘制图像和字符串以及使用颜色和辅助线程的字体对象“。 (强调我的) 我承认,假设线程安全与文档相矛盾始终是一个冒险的主张。 但我相信这是一个文档错误。 我打开了rdar:// 11161530来跟踪它。 请欺骗 ...
  • UIBlurEffectStyle基于Int ,因此不会从String自动转换。 但你可以手动完成。 这是一个带有init的扩展,它将UIBlurEffectStyle案例作为String : extension UIBlurEffectStyle { init?(with string: String) { switch string { case "extraLight": self = .extraLight case ...
  • 要为Steven写的内容添加更多评论: OS X和iOS上的每个绘图最终都是由Open GL完成的。 但是有一些方法可以绘制一条线: 一种是通过CPU将一条线渲染成栅格化图像,然后将生成的栅格化图像发送到GPU以显示它。 另一种方法是将绘图命令发送到GPU,以便GPU将其绘制为光栅化图像。 然后,混合,动画等工作在GPU中生成的光栅化图像上。 如果您手动使用Open GL,那么您通常会这样做。 我不确定像UIBezierPath这样的UIKit绘图采用哪种方式,但OS X对应的AppKit使用方法1,除非你 ...
  • just draw the string 5 times. One time 1(or2) pixels to the left in black One time 1(or2) pixels to the right in black One time 1(or2) pixels above it in black One time 1(or2) pixels below it in black and the final time in white on the place where you ...
  • 我的球没弹跳的原因有两个: 它没有下降,因为我没有附加到我的UIDynamicAnimator对象的gravityBehaviour: UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[self.orangeBall]]; [self.animator addBehavior:gravityBehavior]; 它没有弹跳,因为我需要设置CollisionBehaviour的布尔属性:“Tran ...
  • 首先,我建议您阅读Apple SceneKit文档和一些教程。 Scene Kit是一个3D渲染Objective-C框架,它将高性能渲染引擎与高级描述性API相结合。 Scene Kit支持导入,操作和渲染3D资源,而无需按照OpenGL的方式渲染场景。 http://www.objc.io/issue-18/scenekit.html https://www.weheartswift.com/introduction-scenekit-part-1/ http://www.raywenderlich.c ...
  • 这是你想要的??? 小提琴: https : //jsfiddle.net/pnfh3v4m/ var main = document.getElementById("lol"); for(var i = 0; i < 10; i++){ var ic = document.createElement('a'); ic.setAttribute("uk-icon","icon:heart"); main.appendChild(ic); } is this ...
  • 经过几个小时的环顾四周,我得到了这个工作。 使用错误的上下文来绘制我的观点。 只是不得不删除这一行。 UIGraphicsBeginImageContext(self.bounds.size); So after a couple of hours of looking around, i got this to work. Was using the wrong context to draw my views. Just had to remove this line. UIGraphicsBeg ...
  • OverlayScene的init并不是真的适合做这件事的地方,因为self.view将nil因为当一个场景初始化时它还没有被添加到视图层次结构中。 更好的选择可能是SKScene生命周期方法- (void)didMoveToView:(SKView *)view; 喜欢: - (void)didMoveToView:(SKView *)view { [super didMoveToView:view]; UIButton *button = [[UIButton alloc] initWi ...
  • 这似乎是iOS 5.x中的回归:它发生在5.0和5.1模拟器和5.1设备上,但不在4.3模拟器或4.3.2设备上。 它也特别是字符串绘图似乎被打破 - 如果您所做的只是字符串绘制(避免创建/销毁上下文的开销),崩溃几乎立即发生: -(void)threadFunc:(UIFont *)font { @autoreleasepool { NSString *string = @" "; CGRect r = {{0,0},{50,50}}; UIGraphicsBeginImage ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)