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 Shaveta_Chawla <sh...@knimbus.com> on 2012/11/24 13:32:18 UTC

Finding max value from a fieldvalue using solr query

I have indexed an XML file in solr, which  looks like:

<doc>
<str name="body">ABC</str>
<str name="contentid">282307</str>
<str name="docuid">121422</str>
</doc>
<doc>
<str name="body">MNO</str>
<str name="contentid">272307</str>
<str name="docuid">188422</str>
</doc>

this file has around 100000 documents. what is the way to get maximum value
from the field value "contentid" parsing the whole file.



--
View this message in context: http://lucene.472066.n3.nabble.com/Finding-max-value-from-a-fieldvalue-using-solr-query-tp4022167.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Finding max value from a fieldvalue using solr query

Posted by Luis Cappa Banda <lu...@gmail.com>.
Hello.

You can query by *:* with start=0, rows=1, fl=contentid and sorting by
contentid. Get the bigger/smaller value for that field is from the first
(and only) document returned.

Regards,

- Luis Cappa.
 El 24/11/2012 14:45, "Jack Krupansky" <ja...@basetechnology.com> escribió:

> The "stats" component will give you the minimum and maximum values for
> fields, among other statistics (e.g., number of documents where a field is
> missing).
>
> Just add &stats=true&stats.field=**contentid to your query. The counts
> will be in the "stats" section of the query response.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Shaveta_Chawla
> Sent: Saturday, November 24, 2012 7:32 AM
> To: solr-user@lucene.apache.org
> Subject: Finding max value from a fieldvalue using solr query
>
> I have indexed an XML file in solr, which  looks like:
>
> <doc>
> <str name="body">ABC</str>
> <str name="contentid">282307</str>
> <str name="docuid">121422</str>
> </doc>
> <doc>
> <str name="body">MNO</str>
> <str name="contentid">272307</str>
> <str name="docuid">188422</str>
> </doc>
>
> this file has around 100000 documents. what is the way to get maximum value
> from the field value "contentid" parsing the whole file.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.**
> nabble.com/Finding-max-value-**from-a-fieldvalue-using-solr-**
> query-tp4022167.html<http://lucene.472066.n3.nabble.com/Finding-max-value-from-a-fieldvalue-using-solr-query-tp4022167.html>
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Finding max value from a fieldvalue using solr query

Posted by Jack Krupansky <ja...@basetechnology.com>.
The "stats" component will give you the minimum and maximum values for 
fields, among other statistics (e.g., number of documents where a field is 
missing).

Just add &stats=true&stats.field=contentid to your query. The counts will be 
in the "stats" section of the query response.

-- Jack Krupansky

-----Original Message----- 
From: Shaveta_Chawla
Sent: Saturday, November 24, 2012 7:32 AM
To: solr-user@lucene.apache.org
Subject: Finding max value from a fieldvalue using solr query

I have indexed an XML file in solr, which  looks like:

<doc>
<str name="body">ABC</str>
<str name="contentid">282307</str>
<str name="docuid">121422</str>
</doc>
<doc>
<str name="body">MNO</str>
<str name="contentid">272307</str>
<str name="docuid">188422</str>
</doc>

this file has around 100000 documents. what is the way to get maximum value
from the field value "contentid" parsing the whole file.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Finding-max-value-from-a-fieldvalue-using-solr-query-tp4022167.html
Sent from the Solr - User mailing list archive at Nabble.com.