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 Dotan Cohen <do...@gmail.com> on 2012/11/19 20:40:27 UTC

Best way to retrieve 20 specific documents

Suppose that an application needs to retrieve about 20-30 solr
documents by id. The application could simply run 20 queries to
retrieve them, but is there a better way? The id field is stored and
indexed, of course. It is of type solr.StrField, and is configured as
the uniqueKey.

Thank you for any insight.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Best way to retrieve 20 specific documents

Posted by Dotan Cohen <do...@gmail.com>.
On Mon, Nov 19, 2012 at 10:35 PM, Tomás Fernández Löbbe
<to...@gmail.com> wrote:
> If you are in Solr 4 you could use realtime get and list the ids that you
> need. For example:
> http://host:port/solr/mycore/get?ids=my_id_1,my_id_2...
>
> See http://lucidworks.lucidimagination.com/display/solr/RealTime+Get
>

Thank you Tomás. In fact I am using Solr 4.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Best way to retrieve 20 specific documents

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
If you are in Solr 4 you could use realtime get and list the ids that you
need. For example:
http://host:port/solr/mycore/get?ids=my_id_1,my_id_2...

See http://lucidworks.lucidimagination.com/display/solr/RealTime+Get

Tomás


On Mon, Nov 19, 2012 at 5:27 PM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

> Hi,
>
> How about id1 OR id2 OR id3? :)
>
> Otis
> --
> Performance Monitoring - http://sematext.com/spm/index.html
> Search Analytics - http://sematext.com/search-analytics/index.html
>
>
>
>
> On Mon, Nov 19, 2012 at 2:40 PM, Dotan Cohen <do...@gmail.com> wrote:
>
> > Suppose that an application needs to retrieve about 20-30 solr
> > documents by id. The application could simply run 20 queries to
> > retrieve them, but is there a better way? The id field is stored and
> > indexed, of course. It is of type solr.StrField, and is configured as
> > the uniqueKey.
> >
> > Thank you for any insight.
> >
> > --
> > Dotan Cohen
> >
> > http://gibberish.co.il
> > http://what-is-what.com
> >
>

Re: Best way to retrieve 20 specific documents

Posted by Dotan Cohen <do...@gmail.com>.
On Tue, Nov 20, 2012 at 12:45 AM, Shawn Heisey <so...@elyograg.org> wrote:
> You can also use this query format:
>
> id:(123 OR 456 OR 789)
>
> This does get expanded internally by the query parser to the format that has
> the field name on every clause, but it is sometimes easier to write code
> that produces the above form.
>

Thank you Shawn, that is much cleaner and will be easier to debug when
/ if things go wrong.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Best way to retrieve 20 specific documents

Posted by Otis Gospodnetic <ot...@gmail.com>.
I wanted to be explicit for the OP.

Vut wouldn't that depend on mm if you are using (e)dismax?

Otis
--
Performance Monitoring - http://sematext.com/spm/index.html
Search Analytics - http://sematext.com/search-analytics/index.html




On Mon, Nov 19, 2012 at 6:37 PM, Upayavira <uv...@odoko.co.uk> wrote:

> In fact, you shouldn't need OR:
>
> id:(123 456 789)
>
> will default to OR.
>
> Upayavira
>
> On Mon, Nov 19, 2012, at 10:45 PM, Shawn Heisey wrote:
> > On 11/19/2012 1:49 PM, Dotan Cohen wrote:
> > > On Mon, Nov 19, 2012 at 10:27 PM, Otis Gospodnetic
> > > <ot...@gmail.com> wrote:
> > >> Hi,
> > >>
> > >> How about id1 OR id2 OR id3? :)
> > > Thank, Otis. This was my first inclination (id:123 OR 456), but it
> > > didn't work when I tried. At your instigation I tried then id:123 OR
> > > id:456. This does work. Thanks.
> >
> > You can also use this query format:
> >
> > id:(123 OR 456 OR 789)
> >
> > This does get expanded internally by the query parser to the format that
> > has the field name on every clause, but it is sometimes easier to write
> > code that produces the above form.
> >
> > Thanks,
> > Shawn
> >
>

Re: Best way to retrieve 20 specific documents

Posted by Upayavira <uv...@odoko.co.uk>.
In fact, you shouldn't need OR:

id:(123 456 789) 

will default to OR.

Upayavira

On Mon, Nov 19, 2012, at 10:45 PM, Shawn Heisey wrote:
> On 11/19/2012 1:49 PM, Dotan Cohen wrote:
> > On Mon, Nov 19, 2012 at 10:27 PM, Otis Gospodnetic
> > <ot...@gmail.com> wrote:
> >> Hi,
> >>
> >> How about id1 OR id2 OR id3? :)
> > Thank, Otis. This was my first inclination (id:123 OR 456), but it
> > didn't work when I tried. At your instigation I tried then id:123 OR
> > id:456. This does work. Thanks.
> 
> You can also use this query format:
> 
> id:(123 OR 456 OR 789)
> 
> This does get expanded internally by the query parser to the format that 
> has the field name on every clause, but it is sometimes easier to write 
> code that produces the above form.
> 
> Thanks,
> Shawn
> 

Re: Best way to retrieve 20 specific documents

Posted by Shawn Heisey <so...@elyograg.org>.
On 11/19/2012 1:49 PM, Dotan Cohen wrote:
> On Mon, Nov 19, 2012 at 10:27 PM, Otis Gospodnetic
> <ot...@gmail.com> wrote:
>> Hi,
>>
>> How about id1 OR id2 OR id3? :)
> Thank, Otis. This was my first inclination (id:123 OR 456), but it
> didn't work when I tried. At your instigation I tried then id:123 OR
> id:456. This does work. Thanks.

You can also use this query format:

id:(123 OR 456 OR 789)

This does get expanded internally by the query parser to the format that 
has the field name on every clause, but it is sometimes easier to write 
code that produces the above form.

Thanks,
Shawn


Re: Best way to retrieve 20 specific documents

Posted by Dotan Cohen <do...@gmail.com>.
On Mon, Nov 19, 2012 at 10:27 PM, Otis Gospodnetic
<ot...@gmail.com> wrote:
> Hi,
>
> How about id1 OR id2 OR id3? :)
>

Thank, Otis. This was my first inclination (id:123 OR 456), but it
didn't work when I tried. At your instigation I tried then id:123 OR
id:456. This does work. Thanks.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Best way to retrieve 20 specific documents

Posted by Otis Gospodnetic <ot...@gmail.com>.
Hi,

How about id1 OR id2 OR id3? :)

Otis
--
Performance Monitoring - http://sematext.com/spm/index.html
Search Analytics - http://sematext.com/search-analytics/index.html




On Mon, Nov 19, 2012 at 2:40 PM, Dotan Cohen <do...@gmail.com> wrote:

> Suppose that an application needs to retrieve about 20-30 solr
> documents by id. The application could simply run 20 queries to
> retrieve them, but is there a better way? The id field is stored and
> indexed, of course. It is of type solr.StrField, and is configured as
> the uniqueKey.
>
> Thank you for any insight.
>
> --
> Dotan Cohen
>
> http://gibberish.co.il
> http://what-is-what.com
>