Apache Solr用Pattern替换“前缀”(Apache Solr Replacing “Prefixes” with Pattern)
这是设置。
从mysql中查询
select NULLIF(id,'') as unID <continue with other things..>
在schema.xml中,
<field name='unID' type='unIDType' index... />
同样在schema.xml中,
<fieldType name="unIDType" class="solr.TextField"> <analyzer> <tokenizer class="solr.PatternTokenizerFactory" pattern="^([AZ]{2})?([0-9]{5})$" group="2"/> </analyzer> </fieldType>
- 也在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.
querying from mysql
select NULLIF(id,'') as unID <continue with other things..>
In schema.xml,
<field name='unID' type='unIDType' index... />
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>
- 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 always5 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
最满意答案
这似乎是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.
相关问答
更多-
UIKit绘图是线程安全的:你如何获得图形上下文?(UIKit drawing is thread safe: how do you get a graphics context?)[2023-08-15]
基于一些经验和基于各种文档的经验,我相信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 ...
-
为什么UIKit绘图不能直接使用图形处理器加速(why is UIKit drawing not accelorated by using the graphics processor 'directly')[2024-04-19]
要为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 ...
-
将UIKit转换为SceneKit(Converting UIKit to SceneKit)[2021-08-02]
首先,我建议您阅读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 ...