Zend_search_lucene 限制结果“长度”
我正在使用 lunece 在某个文件中查找字符串或代码号。 我想知道如何“限制”结果内容。
例子: 我正在长文本(大约 500 个字符)中搜索字符串“DC”。
我想要第一个匹配字符串之前的 20 个字符和之后的 20 个字符。
就像这样: “[..]altri inox 0 50 C aria filtrata senza lubrificazione * 1,5 mm 24V DC 10% (altre a richiesta) 2W Classe F IP 54 (IP 65) con connettore) ED 100% 5 ms Serie W * Nel cas[..]"
lucene 是否已经有一个方法或者需要我编写它? 我只找到了highlightMatches()..
I'm using lunece to find in some file a string or a code number.
I would like to know how can i "limit" the results content.
Example:
i was searching for le string 'DC' in a long text (about 500 char).
I would like to have the 20 char before and 20 after the first matched string..
Like that:
"[..]altri inox 0 50 C aria filtrata senza lubrificazione * 1,5 mm 24V DC 10% (altre a richiesta) 2W Classe F IP 54 (IP 65 con connettore) ED 100% 5 ms Serie W * Nel cas[..]"
Does lucene have already a method or have i to write it?
I only found highlightMatches()..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信 lucene 有支持它的功能。但是,您可以在显示结果时使用 php 进行操作。
注意:foreach 有点“原始”。我专注于字符串处理。
I don't believe lucene has a functionality that supports it. However you could do to with php while displaying the results.
Note: The foreach is a little 'raw'. I focused on the string processing.