String length function query in Solr

2019-02-21 13:53发布

I need to find all the documents in my collection for which the length of a certain field exceeds a certain limit. The field's type is string. Is there a function query that returns the length of a string field in Solr?

标签: solr lucene
2条回答
Animai°情兽
2楼-- · 2019-02-21 14:04

The solution is to use Solr's regex capabilities. For example, the following query retrieves all the documents for which the title field is at least 42:

title:/.{42}.*/
查看更多
再贱就再见
3楼-- · 2019-02-21 14:15

Querying by length is not supported out of the box, the most sensible way would be to create a separate (numeric) field and query by this field.

查看更多
登录 后发表回答