Project to provide a fast, simple way to fetch large query result sets for one or more fields
Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src/main/java/org/ads/solr
CHANGES.txt
README.textile
build.xml

README.textile

Description

WHAT?

This add-on lets you query solr and get back a response containing the values of a specific
field or field from documents matching your query.

WAIT, WHAT?

Right. If you want a response with just the ids or whatever of the matching documents, why not
just use the ‘fl’ param? Because that doesn’t perform very well if the number of matching rows
you want back gets past 10k or so.

WHY?

I needed a way to get the just ids for a large number of documents matching a query. Like, millions.
There’s more details on the why in a talk I gave: http://code4lib.org/conference/2011/luker

HOW?

By using a custom Lucene Collector class called FieldCollector. It skips the part of the search
process that creates document objects for every hit and stashes them in the document cache. Instead
it just collects the single field value you’re interested in. See chapter 6.2 of the Lucene book
for some fairly similar examples.

Install

The master branch is currently coded against the 1.4.1 API. There is also a 3.x branch. You’ll need
a checkout or download of solr, obvs.

  1. cd solr/contrib
  2. git clone git://github.com/lbjay/Solr-FieldQuery.git
  3. add the required settings to solrconfig.xml (see below)
  4. ant compile
  5. ant run-example

solrconfig.xml

Add the following anywhere in the

    <searchComponent name="field_query" class="org.ads.solr.FieldQueryComponent" />

    <requestHandler name="field_query" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="echoParams">explicit</str>
            <str name="fl">id</str>
        </lst>
        <arr name="components">
            <str>field_query</str>
            <str>stats</str>
        </arr>
    </requestHandler>

Try it out

http://localhost:8983/solr/select/?q=foo&fl=id&qt=field_query