You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Giri <gi...@gmail.com> on 2010/12/22 16:36:28 UTC

Solr query to get results based on the word length (letter count)

Hi,

I have a solar index that has thousands of records, the title is one of the
solar fields, and I would like to query for title values that are less than
50 characters long. Is there a way to construct the Solr query to provide
results based on the character length?


thank you very much!

Re: Solr query to get results based on the word length (letter count)

Posted by Jonathan Rochkind <ro...@jhu.edu>.
No good way. At indexing time, I'd just store the number of chars in the 
title in a field of it's own.  You can possibly do that solely in 
schema.xml with clever use of analyzers and copyField.

Solr isn't an rdbms.  Best to de-normalize at index time so what you're 
going to want to query is in the index.

On 12/22/2010 10:36 AM, Giri wrote:
> Hi,
>
> I have a solar index that has thousands of records, the title is one of the
> solar fields, and I would like to query for title values that are less than
> 50 characters long. Is there a way to construct the Solr query to provide
> results based on the character length?
>
>
> thank you very much!
>

Re: Solr query to get results based on the word length (letter count)

Posted by Gora Mohanty <go...@mimirtech.com>.
On Wed, Dec 22, 2010 at 9:06 PM, Giri <gi...@gmail.com> wrote:
> Hi,
>
> I have a solar index that has thousands of records, the title is one of the
> solar fields, and I would like to query for title values that are less than
> 50 characters long. Is there a way to construct the Solr query to provide
> results based on the character length?
[...]

One could write a custom query parser, but if one needed that, would it
not be easier to simply index the length of the title value as a separate
field?

Regards,
Gora