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 cs...@hotmail.com on 2008/12/03 01:46:25 UTC
Query ID range? possible?
We are using Solr and would like to know is there a query syntax to retrieve the newest x records? in decending order.?
Our id field is simply that (unique id record identifier) so ideally we would want to get the last say 100 records added.
Possible?
Also is there a special way it needs to be defined in the schema?
<uniqueKey>id</uniqueKey>
<field name="id" type="text" indexed="true" stored="true" required="true" omitNorms="false" />
In addition, what if we want the last 100 records added (order by id desc) and another field.. say media type A for example
<field name="media" type="string" indexed="true" stored="true" omitNorms="true" required="false"/>
Thanks.
-Craig
Re: Query ID range? possible?
Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Dec 3, 2008 at 6:16 AM, <cs...@hotmail.com> wrote:
> We are using Solr and would like to know is there a query syntax to
> retrieve the newest x records? in decending order.?
Not out of the box. You can keep a new field in the schema of date type with
default value of "NOW". Then you can ask for documents sorted desc by this
field.
>
> Our id field is simply that (unique id record identifier) so ideally we
> would want to get the last say 100 records added.
>
> Possible?
>
> Also is there a special way it needs to be defined in the schema?
> <uniqueKey>id</uniqueKey>
> <field name="id" type="text" indexed="true" stored="true"
> required="true" omitNorms="false" />
>
A word of caution. Don't keep the uniqueKey as a text type because (if you
are haven't modified the example schema) text type is tokenized. Keep it as
a string type.
> In addition, what if we want the last 100 records added (order by id desc)
> and another field.. say media type A for example
> <field name="media" type="string" indexed="true" stored="true"
> omitNorms="true" required="false"/>
>
Same as my first suggestion. Keep a date field which defaults to NOW, sort
desc by this field and additionally add your own sort fields.
--
Regards,
Shalin Shekhar Mangar.