使用特殊字符进行Solr排序

时间:2014-08-27 14:07:28

标签: solr

我希望能够按字母顺序对具有本地语言字符的字段进行排序,例如“Ö”,“Ş”或“Ç”(土耳其字符)。

我的solr架构的相关部分如下:

<field name="bookTitle" type="text_tr" indexed="true" stored="true"/>
<field name="bookTitleSort" type="string" indexed="true" stored="false"/>
<copyField source="bookTitle" dest="bookTitleSort"/>

首先,我尝试使用bookTitle asc排序,但结果根本不是字母顺序。然后我添加了一个名为string的{​​{1}}字段,并尝试了bookTitleSort。除了特殊的字符外,它工作得很好。从其中一个字符开始的那些字符位于最后。

2 个答案:

答案 0 :(得分:1)

使用ICUCollationKeyFilter获取可识别区域设置的可用排序顺序。链接的维基页面上有一个示例,它通过TextFieldKeywordTokenizer一起ICUCollationKeyFilter显示如何执行此操作:

<fieldType name="icu_sort_tr" class="solr.TextField">
  <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.ICUCollationKeyFilterFactory" locale="tr" strength="primary"/>
  </analyzer>
</fieldType>

据我所知,tr是土耳其语的正确语言环境,但请随意仔细检查。

答案 1 :(得分:0)

&#39; ICUCollat​​ionKeyFilterFactory&#39;被剥夺了。您需要在模式中将其指定为字段类型,如:

<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-analysis-extras-.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" regex=".*\.jar"/> 
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" regex=".*\.jar" />

由于Collat​​ion libs未包含在默认模式下,因此需要在solrconfig中添加它。在solrconfig中,必须添加&#34; solr-analysis-extras- &#34;,&#34; icu4j - &#34;,&#34; lucene-analyzers-icu- * &#34 ;.小心只添加一次这些库。一切 罐子将被加载一次并可供所有核心使用。您可以使用solr verbose模式检查libs。

bin\solr.cmd start  -f -v

以详细模式启动solr solr可以以 func lost() { for i in 0...colorButtons.count-1 { createBubble(sender: colorButtons[i]) } } func createBubble(sender : UIButton) { sender.frame.origin.x = palleteView.frame.origin.x + sender.frame.origin.x sender.frame.origin.y = palleteView.frame.origin.y + sender.frame.origin.y view.addSubview(sender) let zigzagPath = UIBezierPath() let oX : CGFloat = sender.frame.origin.x let oY : CGFloat = sender.frame.origin.y let eX = oX let eY = oY - CGFloat(randomFloat(min: 50, max: Float(vl_DeviceHeight-50))) let t : CGFloat = CGFloat(randomFloat(min: 20, max: 100)) var cp1 = CGPoint(x: oX - t, y: (oX+eY)/2) var cp2 = CGPoint(x: oX + t, y: cp1.y) let r = random(lower: 0, 1) if r == 1 { let temp : CGPoint = cp1 cp1 = cp2 cp2 = temp } zigzagPath.move(to: CGPoint(x: oX, y: oY)) zigzagPath.addCurve(to: CGPoint(x:eX, y: eY), controlPoint1: cp1, controlPoint2: cp2) CATransaction.begin() CATransaction.setCompletionBlock({ // Every animation added to this transaction is now finished UIView.transition(with: sender, duration:0.1, options:UIViewAnimationOptions.transitionCrossDissolve, animations: { sender.transform = CGAffineTransform(scaleX: 1.1, y: 1.1) // do something }, completion:{ finished in sender.removeFromSuperview() }) }) let pathAnimation : CAKeyframeAnimation = CAKeyframeAnimation(keyPath: "position") pathAnimation.duration = 2 pathAnimation.path = zigzagPath.cgPath pathAnimation.fillMode = kCAFillModeForwards pathAnimation.isRemovedOnCompletion = false sender.layer.add(pathAnimation, forKey: "movingAnimation") CATransaction.commit() } @IBAction func playAgain(_ sender: Any) { newGame() layoutPalleteView(elements: elementString.characters.count) for button in colorButtons { self.palleteView.addSubview(button) self.palleteView.bringSubview(toFront: button) } tableView.reloadData() }

启动solr